Reputation: 87
I have a rather large mvc project which I have broken up into a couple of areas. I created the areas using the add area, and then cut and pasted some of my controllers and views from my main controllers and views folders into the area ones.
When an action is run from a controller in the areas, these seem to execute fine, until they try to return the view and then comes back with this error:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
If I set up a new test area, and create the controller, and view this seems to work fine. Does anyone have any idea what I might be doing wrong, I have been researching this and experimenting for over a day, and have now completely stalled.
Upvotes: 0
Views: 120
Reputation: 7442
Make sure that context.MapRoute(..)
is called in your AreaRegistration.cs
file
Also make sure that your Views folder are in proper hierarchy. i.e. Views => ControllerName
But most importantly, see if the controllers you copied have appropriate namespace i.e.
MvcApplication.Areas.AreaName.Controllers
instead of
MvcApplication.Controllers
Upvotes: 2
Reputation: 315
try specifying the full path to the are in the return view statement : for example
~/Areas/Admin/Views/Category/_CategoryDetails.cshtml
if you are using the default view for that action that is not a problem, otherwise you have to specify the full path.
Upvotes: -1