3 c# asp.net-mvc oauth facebook-oauth
我正在学习asp.net mvc.我正在尝试使用visual studio mvc模板进行示例应用程序.登录系统确定谷歌,但我有与Facebook帐户签名的问题.第一步就完成了.我被重定向关联您的Facebook帐户页面.当我输入我的用户名并单击按钮时,我得到的对象引用未设置为打击代码中"info"变量的对象实例.
public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
{
if (User.Identity.IsAuthenticated)
{
return RedirectToAction("Manage");
}
if (ModelState.IsValid)
{
// Get the information about the user from the external login provider
var info = await AuthenticationManager.GetExternalLoginInfoAsync();
if (info == null)
{
return View("ExternalLoginFailure");
}
var user = new ApplicationUser() { UserName = model.UserName };
var result = await UserManager.CreateAsync(user);
if (result.Succeeded)
{
result = await UserManager.AddLoginAsync(user.Id,info.Login);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
return RedirectToLocal(returnUrl);
}
}
AddErrors(result);
}
ViewBag.ReturnUrl = returnUrl;
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2141 次 |
| 最近记录: |