I am using the default RazorViewEngine, and Area layout configuration, however when i naviagate to a link which uses a view within the area. I get a error stating the View could not be found and searched in the following locations:
~/Views/Applications/Details.cshtml
~/Views/Applications/Details.vbhtml
~/Views/Shared/Details.cshtml
~/Views/Shared/Details.vbhtml
What I find odd is that it looks as though the view engine does not attempt to search the areas location. What adjustments do I need to make to have the view engine search for views in its area.
Here is the related code I used to define 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