我如何可以打开网页浏览器的URL(如IE),并通过凭据 [英] How can i open a url in web browser (such as IE) and pass credentials
本文介绍了我如何可以打开网页浏览器的URL(如IE),并通过凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打开一个页面,需要基本身份验证。 我想基本认证头传递到浏览器以及网址。
I want to open a page that required Basic authentication. I want to pass the Basic authentication header to the browser along with the URL.
我怎样才能做到这一点?
How can i do that?
推荐答案
通过一个头,您可以:
string user = "uuuuuuu";
string pass = "ppppppp";
string authHdr = "Authorization: Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + pass)) + "\r\n";
webBrowserCtl.Navigate("http://example.com", null, null, authHdr);
因为这需要在每个请求的基础上完成的,基本的身份验证更容易的选择是只;
given that this needs to be done on a per-request basis, an easier option for basic auth is to just;
webBrowserCtl.Navigate("http://uuuuuuu:ppppppp@example.com", null, null, authHdr);
这篇关于我如何可以打开网页浏览器的URL(如IE),并通过凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文