【问题标题】:What is minimal configuration needed for .net Windows Azure WebApp work with cshtml?.net Windows Azure WebApp 与 cshtml 一起使用所需的最低配置是什么?
【发布时间】:2015-11-06 21:40:57
【问题描述】:

我想开发一个 .net 应用程序,其中包含一个简单的 index.cshtml。 Azure WebApp 支持 CI,所以我将 index.cshtml 放入了 github 项目。没有 .sln,没有 Visual Studio 文件 - 纯文本文件(好像说我在只有 nano 和 git 的控制台 linux 上)。我将 WebApp 中的默认文档更改为 index.cshtml,提供了包含站点内容的目录路径。

但我确实看到了 You do not have permission to view this directory or page./ 页面和

说明:您请求的页面类型未提供服务,因为 它已被明确禁止。扩展名“.cshtml”可能是 不正确。请查看下面的 URL 并确保它是 拼写正确。

请求的网址:/index.cshtml

如果我尝试去索引directly

那么除了我的 index.cshtml 文件之外,my WebApp 还需要什么才能工作?

【问题讨论】:

  • 我一直这样做,而且效果很好。你的 web.config 中有什么有趣的东西吗?
  • @ChrisGillum:添加了web.config - 没有任何改变=(

标签: c# azure razor azure-web-app-service


【解决方案1】:

您只需添加以下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>

从技术上讲,&lt;system.web&gt; 部分是可选的,但可以帮助您调试问题。

【讨论】:

    【解决方案2】:

    我将添加第二个答案,因为我查看了您的网站,并且您遇到了一个 web.config 无法解决的不同问题。

    默认情况下,站点的物理根目录是site\wwwroot 文件夹。在您的情况下,您的文件位于该文件夹下的 site 子文件夹中,因此它们位于 site\wwwroot\site 中。但是查看您的站点配置,您已将站点根映射为 site,因此它没有指向它应该指向的位置。

    所以只需将映射更改为site\wwwroot\site 而不是site,事情应该会好很多。

    作为替代方案,您可以保留默认的site\wwwroot,而是使用this technique 在您的project = MyWebRoot 文件中设置project = MyWebRoot

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-30
      • 1970-01-01
      • 2020-05-27
      • 2018-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      相关资源
      最近更新 更多