public static MvcForm BeginForm(this HtmlHelper html, string controller = null, string action = null, Action <FormTag> config = null, object routeValues = null) { var form = new FormTag(); form.Method("POST"); if (controller.IsNullOrEmpty()) { controller = html.ViewContext.GetControllerName(); } if (action.IsNullOrEmpty()) { action = html.ViewContext.GetActionName(); } if (config != null) { config(form); } form.Action(UrlHelper.GenerateUrl(null, action, controller, new RouteValueDictionary(routeValues), html.RouteCollection, html.ViewContext.RequestContext, true)); form.NoClosingTag(); html.ViewContext.Writer.Write(form.ToString()); return(new MvcForm(html.ViewContext)); }