Reputation: 298
I'm using areas feature of Asp.net MVC.
Two different areas with same name controllers:
AdminAreaRegistration.cs
UserAreaRegistration.cs
I would like to have a form that posts to the following method:
@using (Html.BeginForm("UserLogin", "Login",
new { area = "", model = this.Model, returnUrl = Request.QueryString["returnUrl"] },
FormMethod.Post, new { @Id = "frmLogin" }))
But i got an error:
How can i solve it with multiple areas have same name controller and post method using Html.BeginForm()?
Upvotes: 0
Views: 1243
Reputation: 855
You have to define the area in the HTML helper tag as below
your area name must be defined in the HTML helper.
@using (Html.BeginForm("UserLogin", "Login",
new { area = "YOUR AREA NAME", model = this.Model, returnUrl = Request.QueryString["returnUrl"] },
FormMethod.Post, new { @Id = "frmLogin" }))
Upvotes: 1