我有一个.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永远不会被设置。
我错过了什么?