0

I have a webbrowser control on my form, through it I am logging into my site's forum, and I am assuming the web browser stores the cookies for the session somewhere as I can then browse the site as my logged in user. This works fine.

I want to be able to create an interface beside my webbrowser that will allow users to download specific files on the page through a HttpWebRequest. But of course when I create the request and attempt to download the file (the url that I got from the html in the webbrowser), it sends me to the login page and that is what gets downloaded because the authorisation isn't there.

I was wondering if anyone could suggest the simplest way of doing this? I have also tried passing the cookies within the browser to the HttpWebRequest cookie collection, but there is minimal cookies in the webbrowser, definately not enough for the authentication as this didn't work.

Any help would be much appreciated.

Thanks in advance.

Christopher Townsend
  • 1,527
  • 1
  • 13
  • 37

1 Answers1

1

I don't think you're going to be able to do what you want to do (not with the WebBrowser control anyway). Essentially you would need to 'borrow' the WebBrowser control's "context", which as far as I can tell you can't do.

Alternatively, can you just intercept the FileDownloaded event and use that to do what you need to do?

Unfortunately, the WebBrowser control is not very flexible, I think it's basically a wrapper around IE but it doesn't really let you do much.

CodingGorilla
  • 19,612
  • 4
  • 45
  • 65