我正在使用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();
}
}