我在該教程後面安裝了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;
}
}
謝謝!這工作:) – Maverick