Problem Reading Cookie in Windows form - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem Reading Cookie in Windows form

salimgherisalimgheri Posts: 2Member
Hi,
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("http://127.0.0.1");



//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.RequestUri);
foreach (Cookie cky in response.Cookies)
{
Console.WriteLine(cky.Name + " = " + cky.Value);
MessageBox.Show(cky.Name + " = " + cky.Value);
}
Sign In or Register to comment.