0

I'm using areas feature of Asp.net MVC.

Two different areas with same name controllers:

Two area with same controller name

AdminAreaRegistration.cs enter image description here

UserAreaRegistration.cs enter image description here

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:

enter image description here

How can i solve it with multiple areas have same name controller and post method using Html.BeginForm()?

Nikunj B. Balar
  • 298
  • 3
  • 21

1 Answers1

1

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" }))
Aravindan
  • 855
  • 6
  • 15