2017-10-13 121 views
0

我在該教程後面安裝了Identity Manager(https://www.scottbrady91.com/ASPNET-Identity/Identity-Manager-using-ASPNET-Identity),該鏈接已共享。對於我的localhost項目,我還沒有SSL,並且需要一種方法來解決當我運行項目時彈出的「需要HTTPS」消息。我在想下面的Startup類可能是我需要做某些事情的地方,但不確定。我也嘗試在Visual Studios中尋找設置,並在IIS中尋找解決方法,但沒有運氣。ASP.NET MVC需要繞過「需要HTTPS」的消息

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

} 

回答

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); 
+0

謝謝!這工作:) – Maverick

0

那麼拍攝,花了一天的時間來環顧四周,但在我發佈這個問題後發現了答案。我發現了一個改變在於加入以下行ApplicationHost.config文件遞交:

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

通過改變在URL中的端口,我能解決這個問題。