Monday, October 12, 2009

Cross domain HTTP Request using JavaScript

My first choice was to use JQuery. You can use jQuery.ajax with dataType="jsonp". However, this won't work unless the servers supports jsonp ( Cross domain HTTP requests are a really interesting topic.

After several tries, I decided to do this using ASP.NET (in the code-behind page):

Uri uri = new Uri("");

if (uri.Scheme == Uri.UriSchemeHttp)


WebRequest request = HttpWebRequest.Create(uri);

request.Method = WebRequestMethods.Http.Get;

WebResponse response = request.GetResponse();

StreamReader reader = new StreamReader(response.GetResponseStream());

return reader.ReadToEnd();


No comments: