How to read HttpResponse in ASP.NET 2.0?

For example, I have an ASP.NET form called by another aspx:

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

I want to do something like this:

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

I need to get what Response.Write is getting as a result or going to a URL, manipulate this response and send something else.

Any help or point in the right direction is welcome.

+3
source share
5 answers

Webclient.DownloadString () is probably what you want.

+3
source
WebClient client = new WebClient();
string response = client.DownloadString(url);
+8
source

HttpWebRequest HttpWebResponse. WebClient

+1

HttpResponse - , HttpRequest. - , , , - . , , .

0
source

WebClient.DownloadString completely did the trick. I also turned around. I looked at HttpModule and HttpHandler when I used WebClient.DownloadFile before.

Thanks to all who responded.

0
source

Source: https://habr.com/ru/post/1697400/


All Articles