The web application I’m working on comes in two parts: the API and the Interface. The API is an ASP.NET application. The interface is written entirely in Javascript (using ExtJS) and one very simple HTML page.
Hosting the Javascript interface in IIS was simple. The ASP.NET application, however, needs to be run in debug mode from Visual Studio 2008. Unfortunately, since I’m on Vista Home Premium, this just doesn’t work (the patch released by Microsoft was apparently for a pre-release version of Vista, and is therefore not installable on the retail version). That’s all fine and good. I can live with using the ASP.NET Development Server for now.
There’s a problem, however. The interface needs to make AJAX calls to the API application. The application runs on port 8888, rather than 80, so any XMLHttpRequest calls will be denied because a change in port number is classified as a change in domain. How do I make AJAX calls to the API application during development, then?
The answer: a proxy. I wrote a very small Classic ASP script (because who needs an entire ASP.NET application for 5 lines of code?) and placed it in the same directory as the Javascript interface:
1 2 3 4 5 6 | Set req = Server.CreateObject("WinHttp.WinHttpRequest.5.1") req.Open "GET", Request.QueryString("url"), false req.Send Response.ContentType = req.GetResponseHeader("Content-Type") Response.Write(req.ResponseText) |
Now, I make AJAX calls to /proxy.asp?url=http://localhost:8888/customers/list. The result is returned as XML which can be gobbled up by ExtJS and used for whatever I want. Of course, there’s no way I would recommend this for a production instance of the application. Ever.
For development purposes, however, it works pretty well. The only thing it needs is a way to preserve the query string. MonoRail throws a fit when I try to add that feature, however.