开发者

ASP.NET redirect a request

I have a webservice x, when handles request to it, it will generate a request to another webservice y and use the response (might contain image or text) from y as the response to the 开发者_StackOverflow中文版original request. I have the following code to make the call, but how can I set the response?

public void ProcessRequest (HttpContext context)
{
    string uri2 = String.Format(CultureInfo.InvariantCulture, "{0}/{1}", Site2Root, context.Request.Url.PathAndQuery);

    HttpWebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create(uri2);
    HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
    ...
 }


You will first need to execute the webRequest by calling GetResponse. Then you can call Response.BinaryWrite() or Response.Write with whatever content you returned from the first call. Here is an example project of this proxy code. It's not the best example but it should get you started.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜