2008-09-23 84 views
3

例如,我有一個是由另一個ASPX稱爲ASP.NET表單:如何閱讀ASP.NET 2.0中的HttpResponse?

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是作爲結果或去網址,操縱該反應,併發回其他東西。

任何幫助或正確的方向點將不勝感激。

回答

3

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

+0

在我看到John Sheehan有相同的答案之前回答。 – 2008-09-23 18:12:51

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

您將需要使用HttpWebRequest和HttpWebResponse對象。你也可以使用WebClient對象

0

一個HttpResponse被髮送回客戶端以響應HttpRequest。如果你想在服務器上處理一些東西,那麼你可以用Web服務調用或頁面方法來完成。不過,我並不完全確定,我明白你首先要做的是什麼。

0

WebClient.DownloadString完全沒有辦法。我已經把自己包裝在這個裏面了......我過去在使用WebClient.DownloadFile的時候看到了HttpModule和HttpHandler。

非常感謝所有回覆的人。