ASP.NET MVC Wish List
Last Updated 03/12/2008
This morning I watched a video from Mix08 of Scott Hanselman’s session on ASP.NET MVC. I enjoyed the presentation, although I’m sure I will have to watch it several more times. The Routing capabilities are phenomenal but they will take a little while to get my head around. For now, the default Routing mechanism should suit my purposes just fine. I can also see that I am going to have to learn about Unit Testing, so that (in Scott’s own words), I don’t “suck”.
I have been developing a site using the new MVC approach, and overall I ahve to say I finally feel right at home in ASP.NET. I still get all the C# and Framework goodness I am used to, but I can now do it in the close-to-the-HTML way that I am familiar with. Let’s face it, until ASP.NET, WordPad was my web IDE of choice.
In the video, Scott asks us to blog and post about what we would like to see done differently in MVC, so that is the purpose of this post. I will use it as a running tally of my MVC Wish List. My first item was addressed in Scott’s presentation: I wanted the ability to route all non-conforming traffic to a default page rather than relying on the web server configuration and 404 files, and all that ugliness. Well, apparently you can already do this by declaring a *catchall Route. When I figure out the mechanics of this I will try to post a sample.
The Wish List:
1. Make UrlHelper.Action() Static
Make appropriate UrlHelper methods (and probably also HtmlHelper) available in a static context. I wanted to add standard navigation to my page in my custom MasterPage, but I could not use the Url.Action( action, controller) method because at that point there is no ViewPage instantiated. I think this would provide a uniform approach to Url writing.
2. Supply a pre-action Controller Event – added 3/11/2008
I think it would be great to have a generic event (or maybe a partial method?) that would execute before the controller begins the action method. This behavior could be simulated now, but each action would need to explicitly call the method. Implementing it this way would ensure that it was executed every time the controller was called. I think this could be great for things like caching, session management, security, logging, etc.
Update: Scott commented below about a possible solution to this already in place. I don’t think it is exactly what I had in mind, but I will experiment with it when I can and report back.
3. Add a TableRow method to HtmlHelper – added 3/12/2008
I’ve been playing with Html.Form<T> and BindingHelperExtensions.UpdateFrom for building and processing form elements. I think both of these are very cool, and I will be posting about them shortly. Since Form elements are frequently presented in a Table, it would be good to have something like Html.TableRow<T>(inputType, label, T.Property) [obviously this is psuedo-code] that would create a simple table row based on the property with two elements:
<tr> <td>label</td> <td><input type="text" name="Property.Name" value="Property.Value"></td> </tr>
The main benefit of this would be automatically generating the correct property name, so that it lined up perfectly with the UpdateFrom functionality. Another benefit would be to have it automatically populate the Value attribute with the current value of the Property. InputType above would ideally be able to accept the results of Form.Select, Form.Textbox, etc., or could be overloaded with an enum and some additional parameters.
OK, so that is the short (and boring) list for now. As I get further into the project, I’m sure I will find more, but as of now I have a lot more to rave about than to complain about. Keep up the great work fellas!