Use HttpWebRequest to mimic Internet Explorer

I can automate the website using HttpWebRequests. This website requires Internet Explorer to work properly. Since I am not using the webBrowser control, the web request simply returns a page notifying me that I need to use Internet Explorer. Is there a way to trick a site into thinking that I am using Internet Explorer, or will I have to use a webBrowser control?

+3
source share
1 answer

Try setting the line UserAgent:

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, but it all depends on the web application you use.

+2
source

All Articles