I use the WebBrowser control in my asp.net application to take screenshots of web pages. I was able to generate images until I changed the application pool account. I gave the new application pool all the necessary rights, and I can view my pages from IE. But when I go to it through web browser management, I get 401.2. I set the "Failed Request Tracking Rules" in my IIS 7.0 and used Fiddler to sniff requests, and I found that the authentication header was wrong.
But webbrowser.navigate has an overloaded method where we can pass custom HTTP headers. How can i install it? I just want to use built-in authentication and don't want to provide username / password in the code, because I may not know this. 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 tweak the header with other details like useragent too?
Nlv
source share