我正在尝试在ASP.Net MVC 5 Web应用程序中使用ASP.Net Identity 2
当我运行我的应用程序时,我有以下屏幕:
Startup.Auth.css
public void ConfigureAuth(IAppBuilder app)
{
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Home/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(10),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
}
我在登录操作中有一个中断点,但没有任何调用。当我在StartUp.Auth类中禁用代码时,应用程序会运行,但身份验证将停止工作。
我不知道问题是什么。我有另一个运行相同功能的应用程序。
这是生成的网址:
http://localhost:23928/Home/Login?ReturnUrl=%2FHome%2FLogin%3FReturnUrl%3D%252FHome%252FLogin%253FReturnUrl%253D%25252FHome%25252FLogin%25253FReturnUrl%25253D%2525252FHome%2525252FLogin%2525253FReturnUrl%2525253D%252525252FHome%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FHome%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FHome%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FHome%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252FHome%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FHome%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FHome%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FHome%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FHome%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FHome%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FHome%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FHome%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FHome%252525252525252525252525252525252FLogin%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252FHome%25252525252525252525252525252525252FLogin%25252525252525252525252525252525253FReturnUrl%25252525252525252525252525252525253D%2525252525252525252525252525252525252FHome%2525252525252525252525252525252525252FLogin%2525252525252525252525252525252525253FReturnUrl%2525252525252525252525252525252525253D%252525252525252525252525252525252525252FHome%252525252525252525252525252525252525252FLogin%252525252525252525252525252525252525253FReturnUrl%252525252525252525252525252525252525253D%25252525252525252525252525252525252525252FHome%25252525252525252525252525252525252525252F
答案 0 :(得分:1)
最后我解决了这个问题。我启用了Windows身份验证。
打开右侧的“属性”面板
将“Windows身份验证”设置为“已禁用”
将“匿名身份验证”设置为“已启用”