net Windows Azure WebApp使用cshtml所需的最低配置是什么
本文关键字:配置 是什么 Azure Windows WebApp 使用 cshtml net | 更新日期: 2023-09-27 18:20:52
我想开发一个.net应用程序,其中有一个简单的index.cshtml。Azure WebApp支持CI,所以我已经将我的index.cshtml放入github项目中。没有.sln,没有visualstudio文件——只有一个文本文件(好像说我在控制台linux上,只有nano和git)。我将WebApp中的默认文档更改为index.cshtml,提供了包含站点内容的目录路径。
但我确实看到了/
页面上的You do not have permission to view this directory or page.
和
描述:您请求的页面类型没有得到服务,因为它已被明确禁止。扩展名".cshtml"可能是不准确的请查看下面的URL,并确保它是拼写正确。
请求的URL:/index.cshtml
如果我尝试直接转到索引。
那么,除了我的index.cshtml文件之外,我的WebApp还需要什么才能工作呢?
您只需要添加以下web.config
文件:
<configuration>
<appSettings>
<add key="webPages:Version" value="1.0"/>
</appSettings>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
从技术上讲,<system.web>
部分是可选的,但将帮助您调试问题。
我将添加第二个答案,因为我查看了您的网站,您遇到了web.config无法解决的另一个问题。
默认情况下,站点的物理根目录是site'wwwroot
文件夹。在您的情况下,您的文件位于site
子文件夹中,因此它们位于site'wwwroot'site
中。但是查看您的站点配置,您已经将站点根映射为site
,所以它没有指向它应该指向的位置。
因此,只需将映射更改为site'wwwroot'site
而不是site
,事情就会更好地工作。
作为替代方案,您可以保留默认的site'wwwroot
,而是使用此技术在.deployment
文件中设置project = MyWebRoot
。