Answered by:
How do you supply basic authentication or userid/password to WebBrowser or Document property programaticlly

Question
-
User-2140751517 posted
So I have the following code in Windows Forms application. What I am trying to do is to access page on my router and click buttons programaticlly. Everything is seems to working fine accept I get a dialog or popup and have to supply userid password via basic authentication form. My question is how do you supply this in the code below or programatically so that I would not get a popup asking for credentials.
this
.webBrowser1 = new System.Windows.Forms.WebBrowser();webBrowser1.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(HandleDocument);webBrowser1.Navigate(@http://192.168.1.1/st_device.html);
private void HandleDocument(object sender, WebBrowserDocumentCompletedEventArgs e){
HtmlDocument document = webBrowser1.Document; HtmlElement disconnectButton = document.GetElementById("disconnect");disconnectButton.InvokeMember(
"click"); HtmlElement connectButton = document.GetElementById("connect");connectButton.InvokeMember(
"click");}
Wednesday, March 28, 2007 10:25 PM
Answers
-
User-2140751517 posted
The answer to the problem above is as below. Someone had answered it for me on MSDN forum. You can do this from code but this will not work you try to hit this url from IE.
webBrowser1.Navigate(@"http://userid:password@192.168.1.1/st_device.html");
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 2, 2007 8:29 AM
All replies
-
User-2140751517 posted
The answer to the problem above is as below. Someone had answered it for me on MSDN forum. You can do this from code but this will not work you try to hit this url from IE.
webBrowser1.Navigate(@"http://userid:password@192.168.1.1/st_device.html");
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 2, 2007 8:29 AM -
User1570265326 posted
The answer to the problem above is as below. Someone had answered it for me on MSDN forum. You can do this from code but this will not work you try to hit this url from IE.
webBrowser1.Navigate(@"http://userid:password@192.168.1.1/st_device.html");
many thanks
i was looking for this :)
Thursday, December 2, 2010 9:47 AM -
User1570265326 posted
The answer to the problem above is as below. Someone had answered it for me on MSDN forum. You can do this from code but this will not work you try to hit this url from IE.
webBrowser1.Navigate(@"http://userid:password@192.168.1.1/st_device.html");
many thanks
i was looking for this :)
Thursday, December 2, 2010 9:47 AM -
User1570265326 posted
The answer to the problem above is as below. Someone had answered it for me on MSDN forum. You can do this from code but this will not work you try to hit this url from IE.
webBrowser1.Navigate(@"http://userid:password@192.168.1.1/st_device.html");
many thanks
i was looking for this :)
Thursday, December 2, 2010 9:47 AM