Enjoying ASP.NET 3.5 Sp1 Routing

I’m not a web developer.

Anyone that knows me knows this.

I’m bad with ASP.NET Web Forms these days in that I understood it when it shipped back in 2002 and I’ve kind of lost track of it in the meantime although I can talk about it at “some level”. I think I was ok up until V2.0 but when all the AJAX bits started to creep in I started to get a bit vague as to which control is generating which lump of script ๐Ÿ™‚

Speaking of which, I can write a bit of JavaScript but it’s not my skill and I fight against it rather than really enjoying it. I like the compiler to find my errors rather than sit staring at a screen for hours because I got some little tiny bit of case-sensitivity wrong somewhere.

That’s not to say that I don’t like the web, of course ๐Ÿ™‚

I like the web as a service infrastructure for my HTTP/WCF/ASMX/Astoria services and I’m pretty happy with Silverlight’s richer web UI as, for me, the developer model offered by .NET is more in line with what I’d hope for than the “developer model” offered by HTML+Javascript.

But today I spent a little bit of time playing with ASP.NET V3.5 Sp1 and its routing feature and it made perfect sense to me.

I have a request for some URL, I have some kind of ASP.NET handler that I want to route it to and there’s no reason to tie the handler of that request to anything physical on my site so why not just define a routing table that links these things together?

I had a bit of a play with it, wrote a couple of handlers, registered them on routes with default values and constraints and it all just worked exactly as I expected it to. To be honest, I found it a lot simpler than trying to author an .ASPX page because there was a lot less to understand – Route, IRouteHandler and IHttpHandler being fairly simple to get your head around.

Naturally, that’s because the content coming out of my handler was trivial – if I’d been doing some kind of fancy page then I’d have got stuck very quickly.

The one thing that seemed a little odd to me was that there is a Routing table of routes but there doesn’t seem to be the concept of “nesting” routes – not entirely sure how much that would/wouldn’t matter in reality.