我目前正在开发一个MVC5网络应用程序,使用ASP.NET Identity 2进行帐户控制,我遇到的具体问题是在>确认电子邮件确认后自动登录用户。 / p>
所以流程如下: 控制器上的确认电子邮件操作如下所示: 奇怪的是,我可以确认电子邮件或签署用户,出于某种原因,如果我同时做这两件事......它不起作用。具体来说,我在这一行得到了一个TimeOutException: 这是非常令人难以置信的,因为我知道db和app服务器不是问题。 我是以错误的方式解决这个问题吗? 提前致谢!
[AllowAnonymous]
public async Task<ActionResult> ConfirmEmail(string userId, string code)
{
// If userId or code is empty, show an error or redirect
if (userId == null || code == null)
{
return View("Error");
}
// Attempt to confirm the email address
var confirmEmailResult = await UserManager.ConfirmEmailAsync(userId, code);
// Retrieve the user (ApplicationUser)
var user = await UserManager.Users.FirstOrDefaultAsync(u => u.Id == userId);
if (user == null)
{
// If the user doesn't exist, redirect home
return RedirectToAction("Index", "Home");
}
// If the confirmation succeeded, sign in the user and redirect to this profile page
if (confirmEmailResult.Succeeded)
{
await SignInManager.SignInAsync(user, false, false);
var url = Url.Action("Profile", "User");
return RedirectToLocal(url);
}
// In all other cases, redirect to an error page
return View("Error");
}
await SignInManager.SignInAsync(user, false, false);
答案 0 :(得分:2)
好的,已找到答案,问题如下,对于每个请求,正在设置级别equals()
的事务。这导致第二次更改(创建)被第一次更改(电子邮件确认),导致超时...
Read Commited
再次感谢您的帮助!