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 you're passing
null
for the action and controller in the first two arguments. Instead, pass the name of your action and controller and it will work.Example, if your action is "Index" and your controller is "Home", then use:
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”