简体   繁体   中英

ASP.NET MVC Need to bypass “HTTPS required” message

I installed Identity Manager ( https://www.scottbrady91.com/ASPNET-Identity/Identity-Manager-using-ASPNET-Identity ) following that tutorial on the link shared. I don't have an SSL yet for my localhost project, and need a way to get around this "HTTPS required" message that pops up when I go to run the project. I'm thinking the Startup class below may be where I need to do something, but not sure. I also tried to look for settings in Visual Studios as well as look around in IIS for a way to get around this but with no luck.

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        var factory = new IdentityManagerServiceFactory();
        factory.IdentityManagerService =
          new Registration<IIdentityManagerService>(Create());

        app.UseIdentityManager(new IdentityManagerOptions { Factory = factory });
    }

    private IIdentityManagerService Create()
    {
        var context =
          new IdentityDbContext(
            @"Data Source=.\SQLEXPRESS;Initial Catalog=AspIdentity;Integrated Security=false");

        var userStore = new UserStore<IdentityUser>(context);
        var userManager = new UserManager<IdentityUser>(userStore);

        var roleStore = new RoleStore<IdentityRole>(context);
        var roleManager = new RoleManager<IdentityRole>(roleStore);

        var managerService =
          new AspNetIdentityManagerService<IdentityUser, string, IdentityRole, string>
            (userManager, roleManager);

        return managerService;
    }

}

IdentityManagerOptions contains a SecurityConfiguration property, which itself contains a RequireSsl property that you can set to false .

var factory = new IdentityManagerServiceFactory();
factory.IdentityManagerService = new Registration<IIdentityManagerService>(Create());

var identityManagerOptions = new IdentityManagerOptions { Factory = factory };
identityManagerOptions.SecurityConfiguration.RequireSsl = false;

app.UseIdentityManager(identityManagerOptions);

Well shoot, took a day to look around but found the answer just after I posted this question. I found a changed filed in the applicationhost.config file that added the following line:

<binding protocol="https" bindingInformation="*:44380:localhost" />

By changing the port in the URL to that, I was able to get around this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM