【问题标题】:Azure App Service Hosting asp.NET core MVC AppAzure 应用服务托管 asp.NET 核心 MVC 应用
【发布时间】:2020-12-13 07:12:27
【问题描述】:

我正在尝试让我们现有的 asp.NET core mvc 应用程序在 azure 应用程序服务中运行。部署工作正常,我期望的所有文件都在服务器上。

遗憾的是,在尝试访问该 url 后,我收到消息“您无权查看此目录或页面”。这是状态码 403。

日志提供了更多见解:

<div id="content"><div class="content-container"><h3>HTTP Error 403.14 - Forbidden</h3><h4>The Web server is configured to not list the contents of this directory.</h4></div><div class="content-container"><fieldset><h4>Most likely causes:</h4><ul>     <li>A default document is not configured for the requested URL, and directory browsing is not enabled on the server.</li> </ul></fieldset></div><div class="content-container"><fieldset><h4>Things you can try:</h4><ul>   <li>If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.</li>    <li>           Enable directory browsing using IIS Manager.           <ol>          <li>Open IIS Manager.</li>          <li>In the Features view, double-click Directory Browsing.</li>             <li>On the Directory Browsing page, in the Actions pane, click Enable.</li>         </ol>   </li>   <li>Verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file.</li>

似乎我应该使用某种登录页面,例如 index.html,但给定的 mvc 项目不存在。

我也找不到此配置的任何文档。即使是展示托管 mvc 应用程序是多么容易的 youtube 视频也无需进行任何进一步的配置。 (比如这个:watch)

如果有人能告诉我哪里出错了,我会很高兴。

提前致谢,

约书亚

【问题讨论】:

  • 您是否尝试将“配置、默认文档”中的项目更改为适合您的场景?
  • 好吧,因为它是一个 mvc 应用程序,所以没有“默认文档”。 wwwroot 文件夹包含我的应用程序的 .dll 文件和我的应用程序的 .exe 文件。此 mvc 项目不存在静态 html 文件。

标签: azure model-view-controller azure-web-app-service


【解决方案1】:

我已经通过 Visual Studio 在 Azure App Service 上部署了一个 .NET Core MVC 应用程序,它工作正常。所以,我注意到在这个过程中,VS 创建了一个 web.config 文件。一旦我通过 Kudu 从应用服务中删除它,应用就停止了。

因此,解决方案是在应用服务环境的wwwroot 文件夹中创建一个web.config 文件。内容如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
  <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\My.Main.Project.dll" 
stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" 
hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

为了记录,该应用程序是在 .NET Core 3.1 上创建的。

【讨论】:

  • 这实际上是主要问题。非常感谢!
猜你喜欢
  • 2020-09-26
  • 2018-02-18
  • 1970-01-01
  • 1970-01-01
  • 2019-10-02
  • 1970-01-01
  • 2020-12-06
  • 2022-07-07
  • 2018-11-29
相关资源
最近更新 更多