MVC Azure无法使用默认路由查找视图或主控,但在本地工作

Kha*_*man 7 html c# asp.net-mvc azure razor

我有一个MVC网站在本地运行良好,但当我将其部署到我的Azure网站时,除了主页索引页面之外,每个网页都会出现此错误.

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Sales/Index.aspx
~/Views/Sales/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Sales/Index.cshtml
~/Views/Sales/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
Run Code Online (Sandbox Code Playgroud)

如有必要,我可以提供更多信息,但我无法在此问题的所有报告中找到任何具有相同问题的人.大多数人合法地将文件的问题放在了错误的地方.但是,我的控制器和视图的结构很好,它们在本地工作.它只能在部署到我的Azure网站时找不到视图.

Kha*_*man 15

在每个视图的属性中,我必须将Build Action更改为Content,并且发布实际部署了.cshtml文件.

  • 在asp.net核心RC2中,您可以在project.json中执行此操作.您在"publishOptions"中包含了"Views"文件夹:{"include":[]}部分 (3认同)