none
Using same cookies of a webBrowser control in a webrequest.

    Question

  • Hello, I am trying to download an image from a webpage.
    I can navigate it with a webbrowser control, and now I want to download an image from it, I got the uri of it, but the trick is, if you are logged in, that image is green, else, that image is red, even in same url.

    So, what I need to do is to download the image using the webbrowser cookies, if I do a httprequest/response from that image without setting up webbrowser cookies it will download the wrong image.
    Thanks.
    Sunday, July 29, 2007 10:34 PM

Answers

  • Gohalien,

    you should be able to transfer the cookies by using something like this:

     

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

    request.CookieContainer = new CookieContainer ();

    request.CookieContainer.SetCookies (myUri, webBrowser1.Document.Cookie);

     

    HTH

    --mc

     

    Monday, July 30, 2007 12:31 AM

All replies

  • Gohalien,

    you should be able to transfer the cookies by using something like this:

     

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

    request.CookieContainer = new CookieContainer ();

    request.CookieContainer.SetCookies (myUri, webBrowser1.Document.Cookie);

     

    HTH

    --mc

     

    Monday, July 30, 2007 12:31 AM
  • It make sens, I will try it and let you know how it works ... I'll search for "Document.Cookie" property for the webBrowser ... I hope that I can save the webBrowser cookies in a custom location like the HTTP req cookies
    Tuesday, June 25, 2013 7:46 AM