0

我按照共享链接上的教程安装了 Identity Manager ( https://www.scottbrady91.com/ASPNET-Identity/Identity-Manager-using-ASPNET-Identity )。我的 localhost 项目还没有 SSL,需要一种方法来绕过当我运行项目时弹出的“需要 HTTPS”消息。我在想下面的 Startup 类可能是我需要做某事的地方,但不确定。我还尝试在 Visual Studios 中查找设置,并在 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;
    }

}
4

2 回答 2

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);
于 2017-10-13T12:45:48.457 回答
0

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

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

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

于 2017-10-13T12:44:55.710 回答