我刚刚开始使用ASP.NET MVC 5(我已经使用了以前的版本)并且我有一个非常奇怪的问题:我使用Visual Studio 2013(完全更新的)ASP.NET模板创建了一个新网站.对于模板选项,我选择了MVC模板,"个人用户帐户"身份验证类型,没有云托管,除了核心MVC库之外没有其他组件.验证选项后,我更新了所有NuGet包.之后我按F5(不打开或修改任何新项目文件).
由于无限重定向循环,浏览器仅打开以显示错误页面:URL显示:
http://localhost:24585/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%252525<snip>
Run Code Online (Sandbox Code Playgroud)
同样,这是使用未经修改的库存MVC模板.我确实检查了登录URL是否在cookie auth选项中定义,看起来很好:
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
Run Code Online (Sandbox Code Playgroud)
唯一可能破坏默认网站的是全局web.config/machine.config文件中的内容,尽管我通常会避免在我的开发框中弄乱它们.在不更新NuGet包的情况下启动模板并不能解决问题.ASP.NET …
asp.net-mvc asp.net-mvc-5 asp.net-identity-2 asp.net-mvc-5.2