我正在使用 NWebSec 和 OWIN 对我的 MVC5 网站进行身份验证。
我遇到的问题是,当 web.config 文件中的 debug = false 时,这种方式:
<compilation debug="false" targetFramework="4.7.2"/>
当我尝试连接到http://localhost时,会自动重定向到https://localhost。
当 debug = true 时,站点工作。我几乎可以肯定这种重定向是由于 NWebSec....
你有什么建议可以进一步调查这个问题吗?或者,给我一个可能是什么问题的线索?
这是配置身份验证的 Startup 类:
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
UrlHelper url = new UrlHelper(HttpContext.Current.Request.RequestContext);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString(url.Action("Login", "Account", new { area = "Security" })),
ExpireTimeSpan = TimeSpan.FromMinutes(15)
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseHsts(options => options.MaxAge(days: 30).IncludeSubdomains());
// Uncomment the following lines to enable logging in with third party login providers
//app.UseMicrosoftAccountAuthentication(
// clientId: "",
// clientSecret: "");
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
//app.UseGoogleAuthentication();
}
}