tags:

views:

20

answers:

1

I have a page on the local intranet that provides information in JSONP format and want external users to be able to use that page for AJAX calls.

For this I want to write an ASPX proxy page that passes the client request to the internal page (on another server) and then sends the unaltered response to the external client.

What would be the easiest way to accomplish this?

A: 

Solved this using the following code in Page_Load:

        var request = (HttpWebRequest)WebRequest.Create("http://jsonsource/");
        var response = (HttpWebResponse) request.GetResponse();
        var json = new StreamReader(response.GetResponseStream()).ReadToEnd();

        Response.ClearHeaders();
        Response.ClearContent();
        Response.Clear();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/json";
        Response.ContentEncoding = Encoding.UTF8;
        Response.Write(json);
        Response.Flush();
Crassy