Reputation: 1109
I have this ASP.NET webapi program that was running smoothly with the help page working as well.
Suddendly something happened and the Help Page won't load anymore.
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/HelpPage/Views/Help/Index.aspx
~/Areas/HelpPage/Views/Help/Index.ascx
~/Areas/HelpPage/Views/Shared/Index.aspx
~/Areas/HelpPage/Views/Shared/Index.ascx
~/Views/Help/Index.aspx
~/Views/Help/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Areas/HelpPage/Views/Help/Index.cshtml
~/Areas/HelpPage/Views/Help/Index.vbhtml
~/Areas/HelpPage/Views/Shared/Index.cshtml
~/Areas/HelpPage/Views/Shared/Index.vbhtml
~/Views/Help/Index.cshtml
~/Views/Help/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
public ActionResult Index()
{
ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
return View( Configuration.Services.GetApiExplorer().ApiDescriptions);
}
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
The correct file is clearly there inside "~/Areas/HelpPage/Views/Help/Index.cshtml" and I have registered all Areas following the WebAPI tutorial. The view engine just can't find it for some unknown reason, help??
EDIT:
Ok I sort of figured something out. When I right click ActionResult and click go to View, it gives me an error and go to nothing.
So , I right click ActionResult and ADDED a view, it creats a new view in ~/Views/Help/Index.cshtml
So someway that Action is not pointing to the correct View page, and I have no idea how to fix that.
Upvotes: 2
Views: 4965
Reputation: 1109
I found the Error, The folder Areas, was accidentally put into a wrong directory when it should be in the root directory
Upvotes: 2
Reputation: 3816
it's because you have a HelpController
in both root and in HelpPage
Area and the view engine can't figure out which one to show.
Please open your RouteConfig.cs file under AppStart and add the namespace of the root controller class as follows to the default route config
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional
},
namespaces: new[] { "yourrootcontrollernamespace" }
);
checkout this youtube video
Upvotes: 0