Ben Scheirman

These fickle bits...

Menu

ASP.NET MVC Preview 2 Update

I’m upgrading Code Camp Server to the latest drop of ASP.NET MVC (which is just an interim release, so you might not yet care) but I wanted to get some first hand knowledge of how the new changes work out.

I won’t go over every change, because The Gu has a great writeup already.  But there are a few thoughts I’d like to share.

Routing

Routing is getting mature, and quick.  The fact that we can use this in our WebForms projects is really cool.  With routing getting more and more features, it is critical that you have extensive tests around your routes.  Imagine that you have an application already deployed.  A single change to the routing assembly (or the registered routes) can have a drastic effect on your application.  Existing links could be broken, new links might not work the way you expected, and you will severly cripple your search engine ranking.

Code Camp Server definitely needs to get an exhaustive set of routing tests to verify each of our URLs is functioning properly.

ActionResult

Instead of having controllers directly render views or redirect to another action, they have extracted this into ActionResult classes.  While the syntax is a bit quirky (“return RenderView”) this is a good design choice in my opinion.  If C# were as flexible as Ruby, we could still have the single “RenderView” method call, and the last statement would actually get returned to the calling method.

Our tests for Code Camp Server will be a lot cleaner.  No more test subclasses.  A lot less mocking as well, since now you can rely on plain old Asserts on the ActionResult .

This ActionResult change never made it to ComponentController though, but it will likely be there in the next drop.

Aside from the readability hiccup with “return” I don’t see any downsides to this change.  Anybody else experience any?

Validation Love from Steven Sanderson

Some people wonder how to do validation, since the existing ASP.NET Validators don’t work with ASP.NET MVC.  I ran across this, where Steven Sanderson shows how to do Model-based Client-side Validation in ASP.NET MVC using Castle Validator.  There’s even a 6–minute screencast!  Keep that kind of stuff coming Steve! 

Comments