我想检查用户是否已经在 ASP.NET MVC4 中使用 facebook 登录。我正在使用 Facebook C# SDK。我有从 facebook 获取 access_token 的代码:
public ActionResult FacebookCallback(string code)
{
var fb = new FacebookClient();
dynamic result = fb.Post("oauth/access_token", new
{
client_id = "XXXXXXXXXXXXXX",
client_secret = "XXXXXXXXXXXXXXXXXXX",
redirect_uri = RedirectUri.AbsoluteUri,
code = code
});
var accessToken = result.access_token;
Session["AccessToken"] = accessToken;
fb.AccessToken = accessToken;
dynamic me = fb.Get("me?fields=first_name,last_name,id,email");
string email = me.email;
FormsAuthentication.SetAuthCookie(email, false);
return RedirectToAction("Index", "Home");
}
我不知道如何检查用户是否已经登录。请帮忙。