Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Sending requst with sent cookies

Sending requst with sent cookies

Scheduled Pinned Locked Moved C#
helpquestioncsharpphpdotnet
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gindi Bar Yahav
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups