这是我登录方法的一部分
if (ModelState.IsValid) {
//some logic to determine if a new user needs created with new program/password requirements
await SignInAsync(NewUser, false); //this executes, but never comes back to do the line below this
if (OldUser.ResellerId.Equals(CurrentReseller.ResellerId)) {
return RedirectToLocal(returnUrl);
}
return RedirectToCorrectReseller(NewUser);
}
这是对MVC 5放入的异步方法的调用
private async Task SignInAsync(ApplicationUser user, bool isPersistent) {
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
当我逐步执行此操作时,它会到达最后一个“}”,看起来它完成了方法,但是调试器停止,并返回到网站,就像它已登录一样,当我选择一个新链接时,它确实显示正确的信息,就好像他们已登录一样,但我无法重定向到登录后发生的任何地方...任何想法?
更新
如果删除异步调用,也会发生这种情况:
private void SignIn(ApplicationUser user, bool isPersistent) {
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
var identity = UserManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
}
答案 0 :(得分:0)
对我来说,似乎只对我有用的是更新Nuget包以获得身份。一定是我遇到的随机错误。我没有其他解释。