I have a problem reading cookies. In the first request, I add a cookie with a method
Response.Cookies.Append("UserName", "Name", new Microsoft.AspNetCore.Http.CookieOptions()
{
Path = "/",
HttpOnly = false,
Secure = false
});
In the next query, I want to read the value from cookies
var name = Request.Cookies["UserName"]
but Request.Cookies is null. But also when I call this method by typing api in the browser
localhost:5555/api/tempController/getCurrenUserName
var name = Request.Cookies ["UserName"] returns me a value, and Request.Cookies contains all the cookies that I see in the browser.
I do not understand why in one case it works in another, it does not work.
source
share