我有一個.NET Core 2 Web應用程序,我想使用ASP.NET身份驗證我的用戶。在.NET Core 1.x上,我的代碼工作正常。AspNet核心身份 - Cookie未在生產中設置
我遷移到.NET Core 2,並且在Visual Studio中本地運行時身份驗證可以正常工作。但是,當我部署到實時環境時,身份驗證停止工作:身份驗證Cookie未在生產中設置。
我Startup.cs代碼如下所示:
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity<AppUser, RavenDB.IdentityRole>()
.AddDefaultTokenProviders();
...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseAuthentication();
}
要登錄,我的代碼看起來是這樣的:
public async Task<ActionResult> SignIn(...)
{
var user = ...; // Load the User from the database.
await this.signInManager.SignInAsync(user, isPersistent: true);
...
}
此代碼本地工作:ASP.NET的身份身份驗證的cookie已設置。但是,當我將其部署到Azure的生產環境中時,cookie永遠不會被設置。
我錯過了什麼?