我如何阅读ASP.NET 2.0中的HttpResponse?

时间:2008-09-23 18:08:14

标签: c# asp.net httpresponse

例如,我有一个由另一个aspx调用的ASP.NET表单:

string url = "http://somewhere.com?P1=" + Request["param"];
Response.Write(url);

我想做这样的事情:

string url = "http://somewhere.com?P1=" + Request["param"];
string str = GetResponse(url);
if (str...) {}

我需要得到任何Response.Write得到的结果或者去url,操纵那个响应,并发回其他东西。

非常感谢任何帮助或正确方向的观点。

5 个答案:

答案 0 :(得分:8)

WebClient client = new WebClient();
string response = client.DownloadString(url);

答案 1 :(得分:3)

Webclient.DownloadString()可能是你想要的。

答案 2 :(得分:1)

您需要使用HttpWebRequest和HttpWebResponse对象。您还可以使用WebClient对象

答案 3 :(得分:0)

HttpResponse是响应HttpRequest发送回客户端的东西。如果您想在服务器上处理某些内容,那么您可以使用Web服务调用或页面方法来执行此操作。但是,我并不完全确定我一开始就明白你要做什么。

答案 4 :(得分:0)

WebClient.DownloadString完全成功了。我把自己弄得太干净了......当我过去使用过WebClient.DownloadFile时,我正在看HttpModule和HttpHandler。

非常感谢所有回复的人。

相关问题