View Full Version : how to read cookies in Winforms

03-26-2009, 06:35 AM

I have Windows Application in which i want to read cookie set in the browser i am also attaching my code with question.

What i am doing I am creating Windows user control which i place in ASP.Net application which read a cookie value from the client machine. But The User Control Display in the ASP.Net application can't read the cookie value. I am also attaching code which i am using in User Control ,

textBox1.Text = "Hello";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");

//Uncomment the following statements to set up proxy, if have
//request.Proxy = new System.Net.WebProxy("http://yourproxyservername: portnumber");
//request.Proxy.Credentials = CredentialCache.DefaultCredentials;

//Define an empty CookieContainer class object
//before the HTTP request is sent
request.CookieContainer = new CookieContainer();

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

//Assign the Cookie property of the HttpWebResponse object to the original
//CookieContainer object in the HttpWebRequest object
response.Cookies = request.CookieContainer.GetCookies(request.Request Uri);
foreach (Cookie cky in response.Cookies)
Console.WriteLine(cky.Name + " = " + cky.Value);
MessageBox.Show(cky.Name + " = " + cky.Value);

Does any one have any idea about this?.. Please help

03-26-2009, 09:26 AM
Does this involve MapPoint?