Home > ASP.NET MVC > ASP.NET MVC Wish List

ASP.NET MVC Wish List

March 10, 2008

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!

Advertisements
Categories: ASP.NET MVC
  1. shanselman
    March 11, 2008 at 1:10 pm

    There is the concept of the ActionFilterAttribute that will give you the pre- and post- behavior you want. You can derive a class, add stuff to it’s OnExecuting and OnExecuted methods and then decorate your Controller Actions with the attribute and they will fire.

  2. March 11, 2008 at 2:24 pm

    Great Scott (bet you hear that a lot!) I’ll look into it shortly.

    It sounds like this approach would be specific to the Action methods though, is that correct? By that I mean you would have to add the attribute to every Action method you wanted to fire the event. If so, I was thinking of a more Controller-global version of the same concept. Actually, I was thinking of it being highly simplified, like using a partial method rather than deriving a class. I’ll know more once I experiment with it some.

  3. mark
    February 16, 2009 at 8:20 am

    Joel

    Did you get any where with point 2? I’m trying to do something very similar at the moment and can’t work out where i should be putting this or how to fit it in.

    Thanks

  4. February 16, 2009 at 8:51 am

    Hi Mark,

    I wish I could help, but unfortunately, I never got back to this aspect of the project.

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: