2
我使用DotNetOpenAuth和MVC 3.我可以使用OpenId進行身份驗證。DotNetOpenAuth如何從OpenId檢索電子郵件和名稱
所以我的URL指向控制器具有附加的OpenID =
下面是一個例子變量:
https://www.google.com/accounts/o8/id?id=DFtOawDkCUoLb3YxPzmrEI59-JiSZiAeR-NWw-0
http://mysite.com/Account/Register?OpenID= .......
如何如何能我收到OpenId帳戶的電子郵件和名稱並顯示給View?
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
LogOnModel lm = new LogOnModel();
lm.OpenID = response.ClaimedIdentifier;
// Check if user exist
MembershipUser user = MembershipService.GetUser(lm.OpenID);
if (user != null)
{
lm.UserName = user.UserName;
FormsService.SignIn(user.UserName, false);
}
return View("LogOn", lm);
case AuthenticationStatus.Canceled:
ViewBag.Message = "Canceled at provider";
return View("LogOn");
case AuthenticationStatus.Failed:
ViewBag.Message = response.Exception.Message;
return View("LogOn");
}