You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.0.0 will introduce changes that help unify API for configuring cookie settings in various ASP.NET Core components.
The current API will be marked [Obsolete] and removed in a future version. Although these obsolete API will continue to function as they do in 1.x, we recommend moving to the new API soon. (See below).
Update your code from the obsolete API to the new API.
Antiforgery
publicvoidConfigureServices(ServiceCollectionservices){services.AddAntiforgery(options =>{// obsoleteoptions.CookieName="AntiforgeryCookie";options.CookieDomain="contoso.com";options.CookiePath="/";options.RequireSsl=true;// new APIoptions.Cookie.Name="AntiforgeryCookie";options.Cookie.Domain="contoso.com";options.Cookie.Path="/";options.Cookie.SecurePolicy=CookieSecurePolicy.Always;});}
Session
publicvoidConfigureServices(ServiceCollectionservices){services.AddSession(options =>{// obsoleteoptions.CookieName="SessionCookie";options.CookieDomain="contoso.com";options.CookiePath="/";options.CookieHttpOnly=true;options.CookieSecure=CookieSecurePolicy.Always;// new APIoptions.Cookie.Name="SessionCookie";options.Cookie.Domain="contoso.com";options.Cookie.Path="/";options.Cookie.HttpOnly=true;options.Cookie.SecurePolicy=CookieSecurePolicy.Always;});}
Cookie authentication
publicvoidConfigureServices(ServiceCollectionservices){// same is applies anywhere CookieAuthenticationOptions is used,// such as `services.AddCookieAuthentication(Action<CookieAuthenticationOptions> configureOptions)`app.AddAuthentication().AddCookie(options =>{// obsoleteoptions.CookieName="AuthCookie";options.CookieDomain="contoso.com";options.CookiePath="/";options.CookieHttpOnly=true;options.CookieSameSite=SameSiteMode.Lax;options.CookieSecure=CookieSecurePolicy.Always;// new APIoptions.Cookie.Name="AuthCookie";options.Cookie.Domain="contoso.com";options.Cookie.Path="/";options.Cookie.HttpOnly=true;options.Cookie.SameSite=SameSiteMode.Lax;options.Cookie.SecurePolicy=CookieSecurePolicy.Always;});}
MVC
publicvoidConfigureServices(ServiceCollectionservices){app.AddMvc().AddCookieTempDataProvider(options =>{// obsoleteoptions.CookieName="TempDataCookie";options.Domain="contoso.com";options.Path="/";// new APIoptions.Cookie.Name="TempDataCookie";options.Cookie.Domain="contoso.com";options.Cookie.Path="/";});}
The text was updated successfully, but these errors were encountered:
2.0.0 will introduce changes that help unify API for configuring cookie settings in various ASP.NET Core components.
The current API will be marked
[Obsolete]
and removed in a future version. Although these obsolete API will continue to function as they do in 1.x, we recommend moving to the new API soon. (See below).For more discussion on this issue, use aspnet/HttpAbstractions#853.
Associated PRs:
aspnet/HttpAbstractions#882
aspnet/Security#1284
aspnet/Security#1285
aspnet/Session#173
aspnet/Mvc#6472
aspnet/Antiforgery#148
Recommended changes
Update your code from the obsolete API to the new API.
Antiforgery
Session
Cookie authentication
MVC
The text was updated successfully, but these errors were encountered: