开发者

Retrieving cookies from HttpResponse

I have a controller action that I call via Ajax in which I set a cookie like this:

Response.Cookies["Notifications"].Value = "false";
Response.Cookies["Notifications"].Expires = DateTime.Now.AddYears(1)开发者_如何学Go;

In another controller action I am checking for this cookie like this:

if(Request.Cookies["Notifications"] != null && 
    Request.Cookies["Notifications"].Value =="false")
//Do something here

The problem is that Request.Cookies["Notifications"] is always null. I have verified that the cookie is getting set via FireBug. I'm testing this via visual studio's web built in web server.


The problem was with the fact that I was also setting this:

Response.Cookies["Notifications"].Secure = true;

And of course the cookie isn't being sent because I'm not using Https.


When in FireBug do you see the cookie sent back in the request? Also you can have a look at raw request to see if it is actually there


Just an idea/advice... You could fire Fiddler to sniff the actual http traffic and see how and if the cookies are being transferred in the http headers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜