Bert Johnson » Blog »

.NET Proxy

I just added a new project to CodePlex:

.NET Proxy consists of two components: an ASPX page for proxying requests to other servers and a JavaScript class for issuing cross-domain requests using the same syntax as XMLHttpRequest. I see it being useful for two scenarios:

SSL Proxy


Requests for would become requests for netproxy.aspx?

JavaScript Proxy

Another common goal is to incorporate content from third-party sites, but JavaScript has a “same origin policy” restriction meaning you can only access files on your own domain. With this proxy, you can GET content from or POST content to any server in the world using the familiar XMLHttpRequest syntax. All methods and properties are wrapped, meaning only the object declaration needs to be changed.


// Pass in the URL for our proxy ASPX page
var bingProxy = new netProxy("netProxy.aspx");
bingProxy.onreadystatechange = function() {
if (bingProxy.readyState == 4)
alert('Source code for\r\n\r\n' + bingProxy.responseText);
}"GET", "", true);

It’s released under the MIT License, meaning you can do pretty much anything you want with it.