ASP.NET MVC - Controller names in nested applications
I have an MVC web a开发者_开发问答pp, and a nested admin application with areas with the same name:
/localhost/videos
/localhost/admin/videos
These are separate projects in the VS solution. The admin
project is deployed into a folder off of the root app
Both Videos
areas have a controller called VideosController
. It appears that MVC is calling the root application's VideosController.Index instead of the admin site's VideosController.Index, but is (correctly) trying to return the admin/areas/videos/views/videos/index view.
I'd rather not have to go in and rename all of the admin controllers. Any suggestions?
What might help is specifying the default namespace.
typically something like this:
ControllerBuilder.Current.DefaultNamespaces.Add("MyProduct.Controllers");
So now, if MVC has two of something, it will have a default to fall back on. You will see a lot of the same issues if you start using Areas.
精彩评论