Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use HttpWebRequest to Simulate Internet Explorer

I am automating a website with HttpWebRequests. The website in question requires Internet Explorer for the web application to work correctly. Because I'm not using a webBrowser control, the web request just returns a page notifying me that I need to be using Internet Explorer. Is there a way to trick the website into thinking that I'm using Internet Explorer, or will I have to use the webBrowser control?

like image 215
Nathan Tornquist Avatar asked May 23 '26 22:05

Nathan Tornquist


1 Answers

Try to set UserAgent string:

public static void PretendToBeIE(HttpWebRequest request)
{
    request.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)";
}

There is no guarantee that it will work though, everything depends on web app you are using.

like image 64
max Avatar answered May 25 '26 10:05

max