0

I have an application that uses an WebBrowser. This webBrowser load local pages (file://PathOfPage.html).

I want to be able to do a request to this page because of I need to get/set cookies in that page.

The problem is that if i use like uri something like this "file://Program Files/..../page.html", WebRequest.Create(uri) give me an UnSupportedException because of that uri.

My code:

Uri uri = webBrowser1.Url;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string cookie = response.Headers.Get("Cookie");

Any suggestions? Thanks!

Bae
  • 892
  • 3
  • 12
  • 26

1 Answers1

0

Check your Uri format (file:///), also helps to specify if its relative or absolute (you well get an exception for that too) Here is some example: var uri = new Uri("file://C/thing/otherthing/whatever.html", UriKind.Absolute);

Hope this help! Tom