Search code examples
asp.netsslmodel-view-controlleridentityidentitymanager

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;
    }

}

Solution

  • 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);