我想向 Web 服务器发出 http 请求 - 我要激活的链接是
http://webserver/cgi-bin/fccgi.exe?w3exec=web.programname&w3serverpool=fcserverpool&optid=headline
它不能是超链接,因为我不希望页面去任何地方只需向该服务器发出请求/
这是通过httpwebrequest完成的吗?...任何人都知道asp.net(vb)中的一个很好的例子
谢谢,
是的,只需执行以下操作:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://webserver/cgi-bin/fccgi.exe?w3exec=web.programname&w3serverpool=fcserverpool&optid=headline");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (response) {
StreamReader reader = new StreamReader(response.GetResponseStream());
reader.ReadToEnd();
}
我相信您正在寻找WebClient
课程。
提供用于向由 URI 标识的资源发送数据和从其接收数据的常用方法。
WebClient client = new WebClient ();
string reply = client.DownloadString (address);