I have just migrated my application from MVC2 to MVC3
And i found that whenev开发者_如何学Cer my login page is loaded the Action attribute remains BLANK
Following is the code :
<% using (Html.BeginForm("ValidateUser", "Account", FormMethod.Post, new { id = "formLogin", name = "formLogin" }))
{ %>;
........
<%}%>;
in Browser it shows like following :
<form name="formLogin" method="post" id="formLogin" action="">
........
</form>
where Action is EMPTY
Please help me in this issue
Thanks,
Manoj
Do you have a default route in the Global.asax.cs? BeginForm uses UrlHelper.GenerateUrl to match up the action/controller names to your route collection. So if you don't have a route that maps to ValidateUser, then it can't generate a URL for it.
maybe you will need to write like this:
@using (Html.BeginForm((string)ViewBag.FormAction, "Home", FormMethod.Post, new { id="myform"}))
{
some code here
}
精彩评论