I use the default RazorViewEngine setting and the area layout configuration, however, when I am on a link that uses a view within the area. I get an error "Cannot find and search" in the following places:
~/Views/Applications/Details.cshtml ~/Views/Applications/Details.vbhtml ~/Views/Shared/Details.cshtml ~/Views/Shared/Details.vbhtml
What I find strange is that it looks like the view engine is not trying to find a location in the area. What adjustments should I make to get the view engine to view the views in my area.
Here is the related code that I used to determine my area.
Global.asax.cs
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteRegistrar.RegisterRoutesTo(RouteTable.Routes); }
ApplicationAreaRegistration.cs
private void RegisterRoutesTo(RouteCollection routes) { routes.MapRoute("Application_default", AreaName + "/{action}/{applicationId}", new { controller = "Applications", action = "Index", applicationDomainId = UrlParameter.Optional }, new { applicationId = @"\d+" }); }
Index.cshtml
@Html.RouteLink(item.Name, "Application_default", new { applicationId = item.Id, action = "Details" })
Physical Directory Layout
Areas \ \Application \Controllers -ApplicationsController.cs \Views -Details.cshtml -ApplicationAreaRegistration.cs
source share