Reputation: 140
On the server side when I received an http request, I am adding a new cookie like this:
HttpContext.Response.Cookies.Add(it);
If I immediately query the HttpContext.Request.Cookies for the name of the cookie I just added, I get it back, although I think I Shouldn't since I am not even done with my request handling, did not send the response to client yet.
Should the Request's and Response's cookie collections be different of each other? Just like http request/response cookie headers.
thanks
Upvotes: 2
Views: 600
Reputation: 100527
This is expected and well documented behavior. See HttpResponse.Cookies :
After you add a cookie by using the HttpResponse.Cookies collection, the cookie is immediately available in the HttpRequest.Cookies collection, even if the response has not been sent to the client.
Upvotes: 4