MVC Html.BeginForm使用区域
我正在使用MVC区域,并在一个名为“testing”的区域中的视图我想有一个表单发布到以下方法:
area: Security controller: AccountController method: logon
我怎样才能做到这一点与Html.BeginForm? 可以这样做吗?
尝试这个:
Html.BeginForm("logon", "Account", new {area="Security"})
对于那些想知道如何使用默认的mvc4模板的人来说
@using (Html.BeginForm("LogOff", "Account", new { area = ""}, FormMethod.Post, new { id = "logoutForm" }))
尝试将区域,控制器,操作指定为RouteValues
@using (Html.BeginForm( new { area = "security", controller = "account", action = "logon" } )) { ... }
将此用于具有HTML属性的区域
@using (Html.BeginForm( "Course", "Assign", new { area = "School" }, FormMethod.Get, new { @class = "form_section", id = "form_course" })) { ... }
@using (Html.BeginForm("", "", FormMethod.Post, new { id = "logoutForm", action = "/Account/LogOff" })) {@Html.AntiForgeryToken() <a class="signout" href="javascript:document.getElementById('logoutForm').submit()">logout</a> }