To prepare for the upcoming changes to SameSite in Chrome 80, I have upgraded my .NET Framework API from 4.6.2
to 4.7.2
.
I created a simple test-endpoint that simply sets a cookie with SameSite=None
:
public class TestController : ApiController
{
public IHttpActionResult Get()
{
var cookie = new HttpCookie("foo", "bar")
{
HttpOnly = true,
Secure = true,
SameSite = SameSiteMode.None
};
HttpContext.Current.Response.SetCookie(cookie);
return Ok();
}
}
This works as expected locally, and the following header is returned:
set-cookie: foo=bar; path=/; secure; HttpOnly; SameSite=None
However, this does not work when publishing to an Azure web app configured with 4.7 as runtime stack. The web app returns the cookie header without SameSite:
Set-Cookie: foo=bar; path=/; secure; HttpOnly
If I set it to Strict
or Lax
it works as expected in Azure too.
Is this an issue with Azure? Is there anything that needs to be configured on the web app to get this working, or perhaps I have to set the cookie in a different way?