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.