Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple controllers in Areas and Main site

I have multiple controllers one in Areas

/Areas/Demo/Admin/AdminController

and other in main site

/Controller/Admin/AdminController

Now getting error

Multiple types were found that match the controller named 'Admin'.

How to resolve the issue? Better if I can change something in Areas/Demo as I have to use same Areas on multiple sites.

like image 469
coure2011 Avatar asked Dec 09 '25 13:12

coure2011


1 Answers

Define namespace in your route. http://msdn.microsoft.com/en-us/library/dd492682.aspx

For example my area "Admin" is mapped like this:

context.MapRoute(
    "Admin_default",
    "Admin/{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    new string[] { "MvcBase.Areas.Admin.Controllers" }
);
like image 65
Lukáš Novotný Avatar answered Dec 12 '25 03:12

Lukáš Novotný



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!