I’m having some issues getting Areas working correctly within MVC 3. I have the following folder structure and an Admin area set up:

I’m trying to navigate from the admin page (Index) to the the other view pages in the Admin area for example Admin/Floor/Create etc… but I get The resource cannot be found error on every url combination i’ve tried for example:
- @Html.ActionLink(“floors”, “Index”, “Floor”, new { area = “Admin” }, null)
- /Floor/Index/
- /Admin/Floor/Index/
None of which work. I managed to use the first ActionLink one to link to the admin index page from outside of the area but it’s no use here.
The area registration looks like this:
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
Can anyone offer some help?
Thankyou
The problem is with your routing. You need to set the default controller to be
AdminController:If you don’t specify this, MVC doesn’t know quite what you’re looking for and actually expects you to navigate to
/admin/adminin order to display the initial view. So change the routing as I’ve mentioned above and then use this action link to get toFloorController.Create():To expand a little, with your routing setup this way, your URLs will look like this:
Update
Having downloaded Maciej Rogoziński’s project, this gives me the same problem that your project currently has. The link from the default action is linking to
/admin/admin/, which as I mentioned earlier, is what your project is looking for because no default controller has been specified for the area routing (this also applies to Maciej’s project). Specifying the default controller allows you to navigate to/admin, which results inAdminController.Index()being invoked. Without specifying that controller, you can only retrieve this view from routing to/admin/admin, which again, is what Maciej’s application is doing.