Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvc 4 beginform with route name

Tags:

asp.net-mvc

I'm generating a form in MVC using @Html.BeginForm(), but my form has to post to my confirmation action which will render the confirmation view.

The confirmation action is easy enough to get to, but the user will be redirected there as well and my mapped route looks like this:

    routes.MapRoute(
        name: "RegisterConfirmationRoute",
        url: "register/confirmation",
        defaults: new { controller = "Account", action = "ConfirmRegistration" }
    );

Am I going about this the wrong way? I don't see how I can get @Html.BeginForm to use the routeName to render the form's action attribute?

Regards, Jacques

like image 276
Jacques Avatar asked Jul 23 '12 14:07

Jacques


Video Answer


1 Answers

You want Html.BeginRouteForm("RegisterConfirmationRoute").

like image 111
Tim Rogers Avatar answered Sep 21 '22 11:09

Tim Rogers