私は以下のコードを1.1で動作させました。.netコア1.1から2.0へのIDのアップグレード
public static IServiceCollection RegisterRepositoryServices(this IServiceCollection services)
{
services.AddIdentity<ApplicationUser, IdentityRole<int>>(
config => { config.User.RequireUniqueEmail = true;
config.Cookies.ApplicationCookie.LoginPath = "/Account/Login";
config.Cookies.ApplicationCookie.AuthenticationScheme = "Cookie";
config.Cookies.ApplicationCookie.AutomaticAuthenticate = false;
config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents()
{
OnRedirectToLogin = async ctx =>
{
if (ctx.Request.Path.StartsWithSegments("/visualjobs") && ctx.Response.StatusCode == 200)
{
ctx.Response.StatusCode = 401;
}
else
{
ctx.Response.Redirect(ctx.RedirectUri);
}
await Task.Yield();
}
};
}).AddEntityFrameworkStores<VisualJobsDbContext, int>()
.AddDefaultTokenProviders();
services.AddEntityFrameworkSqlServer().AddDbContext<VisualJobsDbContext>();
services.AddScoped<IRecruiterRepository, RecruiterRepository>();
services.AddSingleton<IAccountRepository, AccountRepository>();
return services;
}
それは今config.Cookiesを参照するセクションが好きではありません....
私はネットを検索してきたが、私は本当にこれを置き換えるために何かを見つける傾けます。
_Itは今config.Cookiesに言及している部分が好きではありません.... _は非常に曖昧な問題の記述です。あなたは精緻化できますか?コンパイルエラーが出ますか? –
これ以上の4つの異なるCookie構成はなく、1つだけです。 [GitHubのアナウンス]を読んでください(https://github.com/aspnet/Announcements/issues/262) – Tseng
@MartinLiversageいいえ、それはVS2017で赤線ではコンパイルされません。それは廃止されたと言います。 – bilpor