.net Windows Azure WebApp 使用 cshtml 所需的最低配置是什么?
What is minimal configuration needed for .net Windows Azure WebApp work with cshtml?
我想开发一个 .net 应用程序,其中包含一个简单的应用程序 index.cshtml。 Azure WebApp 支持 CI,因此我已将 index.cshtml 放入 github 项目。没有 .sln,没有 visual studio 文件 - 纯文本文件(就好像我在控制台 linux 上只有 nano 和 git)。我将 WebApp 中的默认文档更改为 index.cshtml,提供了包含网站内容的目录路径。
但我确实看到了
You do not have permission to view this directory or page.
在 /
页和
Description: The type of page you have requested is not served because
it has been explicitly forbidden. The extension '.cshtml' may be
incorrect. Please review the URL below and make sure that it is
spelled correctly.
Requested URL: /index.cshtml
如果我尝试转到索引 directly。
那么除了我的 index.cshtml 文件之外还需要什么才能使 my 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
,并使用 this technique 在 .deployment
文件中设置 project = MyWebRoot
。
我想开发一个 .net 应用程序,其中包含一个简单的应用程序 index.cshtml。 Azure WebApp 支持 CI,因此我已将 index.cshtml 放入 github 项目。没有 .sln,没有 visual studio 文件 - 纯文本文件(就好像我在控制台 linux 上只有 nano 和 git)。我将 WebApp 中的默认文档更改为 index.cshtml,提供了包含网站内容的目录路径。
但我确实看到了
You do not have permission to view this directory or page.
在 /
页和
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /index.cshtml
如果我尝试转到索引 directly。
那么除了我的 index.cshtml 文件之外还需要什么才能使 my 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
,并使用 this technique 在 .deployment
文件中设置 project = MyWebRoot
。