HeyItsMe007
HeyItsMe007

Reputation: 101

MVC 3 Form issue

I have just migrated my application from MVC2 to MVC3

And i found that whenever 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

Upvotes: 1

Views: 1440

Answers (2)

Frank
Frank

Reputation: 1

maybe you will need to write like this:

@using (Html.BeginForm((string)ViewBag.FormAction, "Home", FormMethod.Post, new { id="myform"}))
  {
      some code here
  }

Upvotes: 0

GeoChatz
GeoChatz

Reputation: 668

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.

Upvotes: 1

Related Questions