开发者

MVC 3 Form issue

开发者 https://www.devze.com 2023-02-26 10:12 出处:网络
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

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
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消