本文介绍了HTTP身份验证需要与主机的远程连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我正在尝试编写一个程序,该程序连接到一个要求提供凭据并进行某些操作或读取返回的数据的网站.请参见此处 [用户:"admin"密码:"mypass"].
我想知道我该怎么做.编程语言无关紧要.
在此先感谢!
Hi!
I''m trying to write a program which connects to a web site which asks for credentials and do something or read the returned data. See here [user : ''admin'' pass : ''mypass''].
I''m wondering how can I do that. The programming language doesn''t matter.
Thanks in advance!
推荐答案
// Create a request for your URL.
WebRequest request = WebRequest.Create ("http://esihaj.com/phpar");
// If required by the server, set the credentials.
request.Credentials = NetworkCredential("admin", "mypass");
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
// Do something with the response you got
那应该为您做.
干杯!
That should do it for you.
Cheers!
这篇关于HTTP身份验证需要与主机的远程连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!