I used the following code to set a cookie in ASP.NET Core 6, but no cookie is created with this code in my browser.
var options = new CookieOptions()
{
Expires = DateTime.Now.AddDays(2),
Path = "/"
};
Response.Cookies.Append(CookieName, serializer.Serialize(cartItems), options);
Please, if anyone knows what the problem is or if there has been a change in .NET 6, I would appreciate it if they could help
2
Answers
I had used this piece of code in my program class.
and in pipeline
But when I removed these codes, cookies were added
alright, i tested this in asp.net 6 and its working for me. can you try this format?