tags:

views:

27

answers:

2

I stored value in the cookie and can login from my site. But i am trying to get the cookie value from my Win App but it does not return any cookie value. The code that i have used there is given Value

HttpWebRequest webRequest=(HttpWebRequest)WebRequest.Create("http://localhost:9699/CokieTest/Default.aspx");

webRequest.Method = "Post";
webRequest.ContentType = "application/x-www-form-urlencoded";      

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
string cookieValue= response.Cookies["RememberMe"].Value;
A: 

First check if the cookie exist when calling from win app by checking Response.Headers.AllKeys. Maybe the website checks some cookies already sent by your browser with each request, which are not set in windows application. Try simulate you browser exactly from win app.

Xaqron
A: 

In which Browser did you set the cookie? If it's in Chrome or Firefox then you won't be able to access the cookies through HttpWebRequest, and even for newer Internet Explorer versions I'm not sure if you get automatic access to the cookies when going through winhttp...

Michael Stum