I'm wondering whether it's possible to have several nested controllers within one main one in MVC 3? For example:
public class AdminController : Controller
{
public class PagesController : Controller
{
}
//More controllers
}
I've tried this but couldn't get it to work, have modified my routes in global.asx but still nothing. How can I call the correct controller from AdminController
when the url is for example:
/Admin/Pages/Index
It sounds like what you are after is Areas . That will give you the URL routing structure you are seeking, but it does not use "controllers within controllers" to accomplish this.
Instead you will have an Admin area with a Pages controller in that area.
No this is not allowed. The controller factory won't be able to resolve it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.