托管asp.NET核心MVC应用程序的Azure应用程序服务

托管asp.NET核心MVC应用程序的Azure应用程序服务,azure,model-view-controller,azure-web-app-service,Azure,Model View Controller,Azure Web App Service,我正在尝试让我们现有的asp.NET核心mvc应用程序在azure应用程序服务中运行。部署工作正常,我期望的所有文件都在服务器上 遗憾的是,在尝试访问url后,我收到一条消息“您没有查看此目录或页面的权限”。这是状态代码403 日志提供了更多的信息: <div id="content"><div class="content-container"><h3>HTTP Error 403.14 - Forbidden<

我正在尝试让我们现有的asp.NET核心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>
HTTP错误403.14-禁止将Web服务器配置为不列出此目录的内容。最可能的原因是:
  • 未为请求的URL配置默认文档,并且服务器上未启用目录浏览。
您可以尝试的事项:
  • 如果不想启用目录浏览,确保配置了默认文档并且文件存在。
  • 使用IIS管理器启用目录浏览
  • 打开IIS管理器。
  • 在功能视图中,双击目录浏览。
  • 在目录浏览页面的操作窗格中,单击启用。
  • 验证配置/system.webServer/directoryBrowse@enabled属性在站点或应用程序配置文件中设置为true
看起来我应该使用某种登录页,比如index.html,但对于给定的mvc项目,这是不存在的

我也找不到此配置的任何文档。即使是展示mvc应用程序的易用性的youtube视频也不需要做任何进一步的配置。(例如,这个:)

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

提前感谢,


Joshua

我已经通过Visual Studio在Azure应用程序服务上部署了一个.NET核心MVC应用程序,它运行正常。因此,我注意到在这个过程中,VS创建了一个web.config文件。一旦我通过Kudu将其从应用程序服务中删除,应用程序就会停止

因此,解决方案是在App Service environment的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上创建的。

您是否尝试过将“配置、默认文档”中的项目更改为适合您的场景?因为它是mvc应用程序,所以没有“默认文档”。wwwroot文件夹包含我的应用程序的.dll文件和我的应用程序的.exe文件。此mvc项目不存在静态html文件。这实际上是主要问题。谢谢!