Conditionally setting SameSite cookie attribute

If you’ve upgraded to .NET Framework v4.8 you can use HttpCookieFilter in .NET Framework, e.g:

public override void HttpCookieFilter(HttpCookie cookie)
{
    cookie.SameSite = SameSiteMode.None;
}

Why can’t you set it here?

Since this is .NET Framework you can access the Request Context from the HttpContext.Current singleton, e.g:

HttpRequest aspReq = HttpContext.Current.Request;

You can also create a new IRequest from HttpContext.Current with:

IRequest req = HostContext.TryGetCurrentRequest();