Sending requst with sent cookies
-
Hey, I want to ask for your help: i am in the middle of building a program using C#, the program have to read XML file from the net that including the information about the member that logind in (this is a website) and display it in the program. the problem is that when i do the requst it not send any cookies with the requst, so the xml return guest, how can i get with C# the cookies that was sendin the website to send them? example: i have loggind in the website with "gindi bar yahav", "123321" - the web set cookies on my computer, now i want to get those cookies with C# becuse i need to use them when i requst from the XML file. that was the code i used
try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.xml\_file); request.Method = "GET"; // Fetch cookies CookieContainer web\_cookies = new CookieContainer(); CookieContainer cookies = web\_cookies.GetCookies(new Uri("http://otaku-con.co.il")); request.CookieContainer = cookies; // Send HttpWebResponse resp = (HttpWebResponse) request.GetResponse(); st = resp.GetResponseStream(); sr = new System.IO.StreamReader(st); // read all the text in it System.Windows.Forms.MessageBox.Show(sr.ReadToEnd().ToString()); } catch(Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); System.Windows.Forms.Application.Exit(); }
when i get the message it gave me "Array()" what means i dont have any cookies (in the page i tried only to print the cookies [with PHP]) but when i go to the page with the browser i can see all my cookies. someone know what the problem? thanks alot, Yahav.
Gindi Bar Yahav - Web & Software defeloper.