Sunday, September 09, 2007

Proof of concept - Be careful with Environment!

At work, one of my colleague was suggesting using URLMapping available in .net 2.0. So thought will try something and play around with that. It is pretty simple implementation available ready made though we can think of building something to support wildcard or regular expression. Many out there have already built and kept in place - available as free and commercial version.

First, I was trying to build a POC for a URL Mapping feature in .net 2.0.

So, I had the below config in the web.config.

<urlmappings enabled="true">
<add url="~/application/action/view/test" mappedurl="~/app/navigate.ashx?action=view&module=test">
<add url="~/application/enroll" mappedurl="~/default.aspx?action=enroll">
<add url="~/application/register" mappedurl="~/app/navigate.ashx?action=register">

The above stuff worked beautifully when I ran from the VS.Net 2005 editor. The application was running in the Web Dev server. For "http://localhost:2401/application/enroll" it mapped the request to default.aspx. I moved the application to IIS 6.0. Booomm!!! I get 404 error with the http://localhost/urlmapping/application/enroll. Makes sense, because when I try http://localhost:2401/application/enroll, IIS tries to find the default document - ah now IIS could not find any default document, it throws 404 exception.

<urlmappings enabled="true">
<add url="~/application/enroll/<anything>.aspx" mappedurl="~/default.aspx?action=enroll">

When above change was made, it worked fine because, IIS has no roll to play except to hand over the request to ASP.Net engine. Once it comes to environment we have complete control. So it was important to keep proper environment for POC. As you all know Web Dev server runs with a higher privilege that IIS might actually run and this would also cause problem.

In my case it was not that costly but otherwise we should give due respect to the POC environment.