我有这个 ASP.NET webapi 程序,它运行顺利,帮助页面也能正常工作。
突然发生了一些事情,帮助页面不再加载。
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);
}
}
正确的文件显然在“~/Areas/HelpPage/Views/Help/Index.cshtml”中,我已经按照 WebAPI 教程注册了所有区域。视图引擎由于某种未知原因无法找到它,帮助?
编辑:
好吧,我有点想通了。当我右键单击 ActionResult 并单击转到查看时,它给了我一个错误并且什么也没有。
所以,我右键单击 ActionResult 并添加了一个视图,它在 ~/Views/Help/Index.cshtml 中创建了一个新视图
所以不知何故 Action 没有指向正确的视图页面,我不知道如何解决这个问题。