ASP.NET MVC需要绕过" HTTPS要求"信息

时间:2017-10-13 12:38:03

标签: asp.net ssl model-view-controller identity identitymanager

我在链接共享的教程之后安装了Identity Manager(https://www.scottbrady91.com/ASPNET-Identity/Identity-Manager-using-ASPNET-Identity)。我还没有为我的localhost项目提供SSL,并且需要一种方法来解决这个问题" HTTPS要求"我去运行项目时弹出的消息。我认为下面的Startup课程可能是我需要做的事情,但不确定。我还尝试在Visual Studio中查找设置以及在IIS中查找以获得解决此问题的方法,但没有运气。

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

}

2 个答案:

答案 0 :(得分:1)

IdentityManagerOptions包含SecurityConfiguration属性,该属性本身包含RequireSsl属性,您可以将其设置为false

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

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

app.UseIdentityManager(identityManagerOptions);

答案 1 :(得分:0)

好好拍摄,花了一天时间环顾四周,但在我发布这个问题之后找到了答案。我在applicationhost.config文件中找到了一个更改的字段,其中添加了以下行:

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

通过将URL中的端口更改为该端口,我能够解决此问题。