开发者

ASP.NET redirect a request

开发者 https://www.devze.com 2023-03-14 22:36 出处:网络
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 开发者_StackOverf

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

精彩评论

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