在此Official ASP.NET Article之后,我从ASP.NET Core 1.0更新到1.1。但是在编译我的ASP.NET Core项目时,我在AccountController.cs文件中收到以下错误:
错误:
Statement
以下操作方法结束时,错误位于第The call is ambiguous between the following methods or properties: 'System.Security.Claims.PrincipalExtensions.FindFirstValue(System.Security.Claims.ClaimsPrincipal, string)' and 'System.Security.Claims.PrincipalExtensions.FindFirstValue(System.Security.Claims.ClaimsPrincipal, string)'
行:
var email = info.Principal.FindFirstValue(ClaimTypes.Email);
project.json :
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
if (remoteError != null)
{
ModelState.AddModelError(string.Empty, $"Error from external provider: {remoteError}");
return View(nameof(Login));
}
var info = await _signInManager.GetExternalLoginInfoAsync();
if (info == null)
{
return RedirectToAction(nameof(Login));
}
// Sign in the user with this external login provider if the user already has a login.
var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false);
if (result.Succeeded)
{
_logger.LogInformation(5, "User logged in with {Name} provider.", info.LoginProvider);
return RedirectToLocal(returnUrl);
}
if (result.RequiresTwoFactor)
{
return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl });
}
if (result.IsLockedOut)
{
return View("Lockout");
}
else
{
// If the user does not have an account, then ask the user to create an account.
ViewData["ReturnUrl"] = returnUrl;
ViewData["LoginProvider"] = info.LoginProvider;
var email = info.Principal.FindFirstValue(ClaimTypes.Email);
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = email });
}
}
答案 0 :(得分:0)
尝试从依赖项中删除"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final"
。混合来自不同版本的软件包 - 在这种情况下,RTM和1.1.0之前通常会导致API模糊不清。