Class CookiePolicyOptionsExtensions
Extension class containing cookie policies (work around for same site).
public static class CookiePolicyOptionsExtensions
- Inheritance
-
CookiePolicyOptionsExtensions
- Inherited Members
Methods
DisallowsSameSiteNone(string)
Checks if the specified user agent supports "SameSite=None" cookies.
public static bool DisallowsSameSiteNone(string userAgent)
Parameters
userAgent
stringBrowser user agent.
Returns
- bool
True, if the user agent does not allow "SameSite=None" cookie; otherwise, false.
Remarks
Incompatible user agents include:
- Versions of Chrome from Chrome 51 to Chrome 66 (inclusive on both ends).
- Versions of UC Browser on Android prior to version 12.13.2.
- Versions of Safari and embedded browsers on MacOS 10.14 and all browsers on iOS 12.
HandleSameSiteCookieCompatibility(CookiePolicyOptions)
Handles SameSite cookie issue according to the https://docs.microsoft.com/en-us/aspnet/core/security/samesite?view=aspnetcore-3.1. The default list of user agents that disallow "SameSite=None", was taken from https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/.
public static CookiePolicyOptions HandleSameSiteCookieCompatibility(this CookiePolicyOptions options)
Parameters
options
CookiePolicyOptionsCookiePolicyOptionsto update.
Returns
- CookiePolicyOptions
CookiePolicyOptions to chain.
HandleSameSiteCookieCompatibility(CookiePolicyOptions, Func<string, bool>)
Handles SameSite cookie issue according to the docs: https://docs.microsoft.com/en-us/aspnet/core/security/samesite?view=aspnetcore-3.1 The default list of user agents that disallow "SameSite=None", was taken from https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/.
public static CookiePolicyOptions HandleSameSiteCookieCompatibility(this CookiePolicyOptions options, Func<string, bool> disallowsSameSiteNone)
Parameters
options
CookiePolicyOptionsCookiePolicyOptionsto update.
disallowsSameSiteNone
Func<string, bool>If you don't want to use the default user agent list implementation, the method sent in this parameter will be run against the user agent and if returned true, SameSite value will be set to Unspecified. The default user agent list used can be found at: https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/.
Returns
- CookiePolicyOptions
CookiePolicyOptions to chain.