Jacques
Jacques

Reputation: 7135

mvc 4 beginform with route name

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

Upvotes: 6

Views: 2590

Answers (2)

jaminto
jaminto

Reputation: 3955

Did you try:

Html.BeginForm("ConfirmRegistration", "Account")

Am i misunderstanding your question?

Upvotes: 1

Tim Rogers
Tim Rogers

Reputation: 21713

You want Html.BeginRouteForm("RegisterConfirmationRoute").

Upvotes: 13

Related Questions