ASP.NET MVC Preview 2 Update
Saturday, May 03 2008 2 Comments
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!


Dmitriy Nagirnyak
5.06.2008
1:51 AM
Ben, the changes are exciting enough, but I'd not jump into everything just now. Nor for a new project, nor for existing ones.-- Routing --Very interesting and nice.But URL-Rewriting will take great piece in ASP.NET applications for a while.I'm not sure I'm ready to use it in WebForms. In ASP.NET MVC it's de-facto.-- Action Result --The same. Good idea and, probably, implementation.But we can live without it.http://dnagir.blogspot.com/2008/03/mvc-controller-action-return-values.html-- Validation --Steven just used Castle Validators and wrote script generator for LiveValidation JS library.It was available for ages with MonoRail, but for Prototype JS library.So nothing really great still.ASP.NET MVC is evolving, but not that fast. For now it just picks everything that has already been done before (reinventing the wheel?).Can you agree?Cheers.