0

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.

JP Edwards
  • 87
  • 12

2 Answers2

2

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
U.P
  • 7,357
  • 7
  • 39
  • 61
  • Hi - thanks for this. It seems that I have both of these set up correctly - public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Rigoletto_default", "Rigoletto/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); And the views are set up as Views => ControllerName => View Name – JP Edwards Jul 10 '13 at 10:57
-1

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.

codetantrik
  • 315
  • 2
  • 9
  • Not necessarily true. Besides, OP didn't mention calling views with names. – U.P Jul 10 '13 at 10:50
  • Hi - Thanks for the answer. This comes up with the same error. I am guessing that it might be to do with the view engine, as per the error message in my main post. – JP Edwards Jul 10 '13 at 11:02