Html.BeginForm and HTML Attributes w/o specifying Controller and Action

Why would you not just use plain html?

<form id="inactivate-form" method="post" >
</form>

Similar to @nick-olsen's answer use null for the action/controller parameters:

@Html.BeginForm(null, null, FormMethod.Post, new Dictionary<string, object>() {{ "id", id }}

The BeginForm method eventually calls System.Web.Mvc.RouteValuesHelpers.MergeRouteValues which looks up the action and controller names from the RequestContext.RouteData if they're null posting back to the same action/controller as the form was created from.


You could create a custom extension that adds an 'Id-ed' form:

public static MvcForm BeginIdedForm(this HtmlHelper htmlHelper, string id)
{
    return htmlHelper.BeginForm(null, null, FormMethod.Post, new Dictionary<string, object>() { { "id", id } });
}

Usage then just becomes

using(Html.BeginIdedForm("inactiveate-form"))