Parameters were reordered in BeginForm()

Last post 10-30-2008 1:42 AM by Simon.Sanderson. 2 replies.

Sort Posts:

  • Parameters were reordered in BeginForm()

    10-17-2008, 5:24 AM
    • Member
      point Member
    • canton
    • Member since 10-17-2008, 9:02 AM
    • Posts 4

    In the process of migrating from MVC Preview 5 to Beta, I discovered an API change that bugs me a lot.

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

    was changed to

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

    Notice that the position of controllerName and actionName got interchanged. This can't be detected by compiler, and must be fixed manually.

    I understand this is more consistent to ActionLink(label, action, controller). And I also understand API in Preview versions is subject to huge changes. But many of us will be glad to see such changes documented in the Release Notes.

  • Re: Parameters were reordered in BeginForm()

    10-17-2008, 12:57 PM
    Answer
    • Contributor
      5,514 point Contributor
    • Eilon
    • Member since 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 945
    • AspNetTeam

    Hi there,

    Sorry about forgetting this in the release notes. We did quite a few renames and reordered some parameters and must have missed that change. I think we missed it because in the "diff" that we did this change doesn't show up because renamed the method as well. The diff tool just thought we deleted the old Form() methods and added the brand new BeginForm() methods, so the parameter reordering didn't show up.

    The number of changes like this should be much smaller now that the Beta is released, so I hope we don't run into this issue again. I'm glad that you at least found the issue in your app and fixed it!

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: Parameters were reordered in BeginForm()

    10-30-2008, 1:42 AM
    • Member
      2 point Member
    • Simon.Sanderson
    • Member since 10-30-2008, 1:24 AM
    • Brisbane, Australia
    • Posts 1

    I have just spent a significant amount of time trying to trace why, after installing the MVC Beta, my forms were being rendered thus:

    <form action="" method="post">
    :
    :
    </form>

    where the action attribute is empty.  The reason, rather tersely, is due to the low save observation made by canton where the controller and action parameters have been re-ordered in the BeginForm() method.  I am suprised that more e-noise has not been made about this change.

    Perhaps there is a case for a more strongly typed classes for Action and Controller names to help prevent similar annoyances like this from occuring in future?  I know I shall be looking to implement such framework functionality asap .....

Page 1 of 1 (3 items)