带重载的Html.BeginForm导致表单动作为'/ cgi-bin?action = Index& controller = Home',因此HomeController被绕过 [英] Html.BeginForm with overload causes form action to be '/cgi-bin?action=Index&controller=Home' and so the HomeController is bypassed
问题描述
因为我想为表单元素分配一个id,我的代码是 @using(Html.BeginForm(null,null,FormMethod.Post,new {id =indexform}))
这导致标记< form action =/ cgi-bin?action = Index& amp; controller = Home 我的HomeController
注意'/ cgi-bin'。这可能是问题,我认为罪魁祸首可能是参数'FormMethod.Post',但我不能在这里输入null。
(顺便说一句,使用jQuery var form = $(#btnShowProperty)。closest(form);
)
I
问题在于混合网页和mvc,尤其是使用MapPageRoute和MapRoute在Route.config中。查看完整答案 @ Url.Action(Action,Controller )返回/ cgi-bin?action =动作&控制器=控制器
Because I wanted to assign an id to a form element my code was @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "indexform"}))
This resulted in markup <form action="/cgi-bin?action=Index&controller=Home" id="indexform" method="post" style="position: relative;">
My HomeController ActionResult Index
was completely bypassed.
Notice the '/cgi-bin'. This might be the problem and I think the culprit may be parameter 'FormMethod.Post' but I could not enter null there.
(BTW I worked around the id requirement by using jQuery var form = $("#btnShowProperty").closest("form");
)
I did quite a bit of Googling on this with no luck.
The problem is mixing web pages and mvc especially using MapPageRoute AND MapRoute in Route.config. See full answer @Url.Action("Action", "Controller") returns "/cgi-bin?action=Action&controller=Controller"
这篇关于带重载的Html.BeginForm导致表单动作为'/ cgi-bin?action = Index& controller = Home',因此HomeController被绕过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!