I'm using WebBrowser control in my asp.net application to generate screenshots of web pages. I was able to generate images till I changed the application pool account. I've given the new application pool all the necessary rights and I'm able to browse my pages from IE. But when I navigate to it through the web browser control programatically I'm getting 401.2. I've setup "Failed request tracing rules" in my IIS 7.0 and have used Fiddler to sniff the requests and I've found that the authentication header is not right.
But the webbrowser.navigate has an overloaded method where we can pass custom http headers. How can I set it? I just want to use the integrated authentication and don't want to give the username/password in the code because I might not know it. But still I tried the following code with no luck.
System.Uri uri = new Uri(myUrl);
byte[] authData = System.Text.UnicodeEncoding.UTF8.GetBytes("user: passwd");
string authHeader = "Authorization: Basic " + Convert.ToBase64String(authData) + "\r\n";
myBrowser.Navigate(uri, "", null, authHeader);
Any ideas how to set the header with other details such as useragent too?