NWebSec is redirecting to HTTPS in release mode

105 Views Asked by At

I am using NWebSec and OWIN to authenticate to my MVC5 web site.

The problem I am having is that when debug = false in web.config file, this WAY:

<compilation debug="false" targetFramework="4.7.2"/>

when I try to connect to http://localhost, automatically is redirected to https://localhost.

When debug = true, site works. I am almost sure that this redirection is due to NWebSec....

Do you have an advice to investigate further this issue? or maybe, give me a clue of what may be the problem?

This is the Startup class that configured authentication:

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();
    }
}
0

There are 0 best solutions below