ASP.Net MVC BeginForm - Beta API Change

The refactoring of the helper method Html.Form in MVC to Html.BeginForm was published in the release notes as a simple renaming. During the beta upgrade process we noticed that a lot of our forms were rendering with blank actions.

If you too are having trouble with your forms, it is worth noting that the API has changed in a subtle but EXTREMELY significant way. The orignal method, whose signature looked like:

public static IDisposable Form(this HtmlHelper helper, string controllerName, string actionName)

Has been changed to read:

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName)

Note that the parameters have been interchanged! So if you were using magic string-ness to get actions into your forms, you now have a bigger upgrade job than you thought. You will need to switch the parameter strings and put your controller where your action is - and vice versa.

This was tracked down in my team by Simon Sanderson (who we are assured is unrelated to MVC guru Steve). There is a confession of sorts from the MVC team here.

October 30, 2008 16:19 by steven.burman
E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 6. 2009 13:36