Question

For example, I have an ASP.NET form that is 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 whatever Response.Write is getting as a result or going to url, manipulate that response, and send something else back.

Any help or a point in the right direction would be greatly appreciated.

Was it helpful?

Solution

Webclient.DownloadString() is probably want you want.

OTHER TIPS

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

You will need to use the HttpWebRequest and HttpWebResponse objects. You could also use the WebClient object

An HttpResponse is something that is sent back to the client in response to an HttpRequest. If you want process something on the server, then you can probably do it with either a web service call or a page method. However, I'm not totally sure I understand what you're trying to do in the first place.

WebClient.DownloadString totally did the trick. I got myself too wrapped up in this one.. I was looking at HttpModule and HttpHandler, when I had used WebClient.DownloadFile in the past.

Thank you very much to all who've replied.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top