For example, I have an ASP.NET form that is called by another aspx:
例如,我有一个由另一个aspx调用的ASP.NET表单:
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.
我需要得到任何Response.Write得到的结果或者去url,操纵那个响应,然后发回别的东西。
Any help or a point in the right direction would be greatly appreciated.
任何帮助或正确方向的一点将不胜感激。
5 个解决方案
#1
3
Webclient.DownloadString() is probably want you want.
Webclient.DownloadString()可能是你想要的。
#2
8
WebClient client = new WebClient();
string response = client.DownloadString(url);
#3
1
You will need to use the HttpWebRequest and HttpWebResponse objects. You could also use the WebClient object
您将需要使用HttpWebRequest和HttpWebResponse对象。您还可以使用WebClient对象
#4
0
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.
HttpResponse是响应HttpRequest发送回客户端的东西。如果您想在服务器上处理某些内容,那么您可以使用Web服务调用或页面方法来执行此操作。但是,我并不完全确定我一开始就明白你要做什么。
#5
0
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.
WebClient.DownloadString完全成功了。我把自己也包裹在这一个......我在看过HttpModule和HttpHandler,当时我曾经使用过WebClient.DownloadFile。
Thank you very much to all who've replied.
非常感谢所有回复的人。
#1
3
Webclient.DownloadString() is probably want you want.
Webclient.DownloadString()可能是你想要的。
#2
8
WebClient client = new WebClient();
string response = client.DownloadString(url);
#3
1
You will need to use the HttpWebRequest and HttpWebResponse objects. You could also use the WebClient object
您将需要使用HttpWebRequest和HttpWebResponse对象。您还可以使用WebClient对象
#4
0
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.
HttpResponse是响应HttpRequest发送回客户端的东西。如果您想在服务器上处理某些内容,那么您可以使用Web服务调用或页面方法来执行此操作。但是,我并不完全确定我一开始就明白你要做什么。
#5
0
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.
WebClient.DownloadString完全成功了。我把自己也包裹在这一个......我在看过HttpModule和HttpHandler,当时我曾经使用过WebClient.DownloadFile。
Thank you very much to all who've replied.
非常感谢所有回复的人。