Answered by:
How can I access a web page protected with username password and show it in webview.

Question
-
Hi,
I am using a webview control and I want to access a webpage which asks for user name and password. I have the username and password but I dont want to prompt the user for credentials, how can I pass username and password with the url and login and access the webpage???
Example:
I want to access the modem configuration from web view. It asks for username and password before showing the interface.
Any suggestions?
Code :
HttpClientHandler handler = new HttpClientHandler();
handler.Credentials = new NetworkCredential("admin", "password");
HttpClient client = new HttpClient(handler);
string body = await client.GetStringAsync(@"http://192.168.1.1"); // throws exception on this line
This is how I am trying to access the modem configuration interface but getting exception.
Rohit
- Edited by Rohit2303 Wednesday, December 4, 2013 2:09 PM
Wednesday, December 4, 2013 11:24 AM
Answers
-
Solution here (written in C#, but you can adapt it):
http://blogs.msdn.com/b/wsdevsol/archive/2013/10/31/webview-single-sign-on.aspx
Matt Small - Microsoft Escalation Engineer - Forum Moderator
If my reply answers your question, please mark this post as answered.
NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.- Marked as answer by Matt SmallMicrosoft employee, Moderator Monday, December 9, 2013 2:55 PM
Wednesday, December 4, 2013 3:58 PMModerator
All replies
-
What kind of authentication is it using? Windows auth, Basic, Digest?
Matt Small - Microsoft Escalation Engineer - Forum Moderator
If my reply answers your question, please mark this post as answered.
NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.Wednesday, December 4, 2013 3:35 PMModerator -
Basic
username and password.
Like we see when we try to access the modem or the router from browser.
Rohit
Wednesday, December 4, 2013 3:41 PM -
Solution here (written in C#, but you can adapt it):
http://blogs.msdn.com/b/wsdevsol/archive/2013/10/31/webview-single-sign-on.aspx
Matt Small - Microsoft Escalation Engineer - Forum Moderator
If my reply answers your question, please mark this post as answered.
NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.- Marked as answer by Matt SmallMicrosoft employee, Moderator Monday, December 9, 2013 2:55 PM
Wednesday, December 4, 2013 3:58 PMModerator