random .NET and web development musings

I simultaneously work on multiple web projects, and have a back catalogue of scores of sites that could need my attention at any time.

I always run my sites locally in a fully fledged IIS site (rather than using Cassini) which means each site needs its own hostname.

Until recently I had been managing this with my hosts file, simply adding a new line:

127.0.0.1  mysite.dev

for each site. However last week I reached breaking point as my hosts file was about 3 pages long.

Enter Velvet. Velvet adds wildcard support to your hosts file by acting as a simple DNS server that you can run stand alone or (preferably) as a windows service.

I have now reduced 3 pages of hosts entries into a two lines:

127.0.0.1  *.dev
127.0.0.1  *.*.dev

actually theres a few others, such as wildcard mappings to my colleagues machines:

192.168.0.2  *.jim
192.168.0.2  *.*.jim
192.168.0.3  *.bob
192.168.0.3  *.*.bob

This means I now rarely ever need to touch my hosts file, at least not for standard day-to-day project work :)

Ultra time saving win.

Check out the project on github.

Feature suggestions welcome!

If you do:

Response.StatusCode = 503;

from an ASP.NET request, you will most likely get a response that looks like this:

HTTP/1.1 503 Service Unavailable
Cache-Control: private
Content-Type: text/html
X-Powered-By: ASP.NET
Date: Mon, 27 Sep 2010 17:23:20 GMT
Content-Length: 27

The service is unavailable.

I.E. “The service is unavailable” is the only content returned, regardless of what your response contained. This is because http.sys in IIS is overriding your response with default custom error behaviour. Great. Fix it like this:

Response.StatusCode = 503;
Response.TrySkipIisCustomErrors = true;

You can then return whatever content you like 😀