I have been looking for answers to all this everywhere, but I cannot find them. I basically have an MVC application setup, and I use the built-in AttributeRouting for my routes.
The folder structure is as follows:
- Models
- representation
- Controllers
- Areas
- Users
- MemberAreaRegistration.cs
- Controllers
- Views
And then I will connect my routes in global.asax as follows:
public class Application : System.Web.HttpApplication { protected void Application_Start(){ AreaRegistration.RegisterAllAreas();
So MemberAreaRegistration.cs is simple.
namespace App.Web.Areas.Member { public class MemberAreaRegistration: AreaRegistration { public override string AreaName { get { return "Member"; } } } public override void RegisterArea( AreaRegistrationContext context){ } }
And I'm trying to connect it using attributes ...
/areas/member/controllers/homecontroller.cs
// ... [Route("member/account")] public ActionResult Account() { return View(); } // ...
The problem is that it finds the route, but it cannot find the representation. I get the following error:
The "Account" view or its wizard is not found or if the viewing mechanism does not support the found locations. The following places were searched:
~ / Views / Home / Account.aspx
~ / Views / Home / Account.ascx
~ / Views / Shared / Account.aspx
~ / Views / Shared / Account.ascx
~ / Views / Home / Account.cshtml
~ / Views / Home / Account.vbhtml
~ / Views / Shared / Account.cshtml
~ / Views / Shared / Account.vbhtml
By all accounts, this should work fine - and if not, I expect ~/area to at least be on the path that the search is trying to do. Do I have to connect something extra to perform this function?
I am using ASP.NET MVC 5.0
If I rigidly set the absolute presentation path, it works. Obviously, this is not a good situation. I would prefer that he find a representation outside the convention. But if I type return View("~/areas/member/views/home/account.cshtml"); I will get the view back, so I know that it can access the file and that it is correct.
Here is my RouteConfig.cs per request
RouteConfig.cs
public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) {