Azure App Service .msg 文件与其余文件一起保存在 wwwroot 中,但说找不到文件?

Azure App Service .msg File saved in wwwroot with rest of files, but says file not found?

我正在将文件保存到 Azure 应用服务中 wwwroot 的临时文件夹中。

但是当我尝试打开或获取文件时,它说找不到文件。如果我在本地主机服务器下的机器上测试它,它就可以工作。它不适用于 Azure 应用服务?

是不是因为是.msg文件?

FileZilla Snippet & Web page result

对 Web 应用程序文件的访问受底层 Web 服务器的限制,所以这不是因为扩展名。您可以通过在应用程序根目录中创建一个 web.config 文件来启用对目录的匿名访问,该文件的内容位于 this guide:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <location path="{your-temp-directory}" allowOverride="false">
      <system.webServer>
         <directoryBrowse enabled="false"/>
         <defaultDocument>
            <files>
               <!-- When requesting a file listing, don't serve up the default 
               index.html file if it exists. -->
               <clear />
            </files>
         </defaultDocument>
         <security>
            <authorization>
               <!-- Allow all users access to the Public folder -->
               <remove users="*" roles="" verbs="" />
               <add accessType="Allow" users="*" roles="" />
            </authorization>
            <!-- Unblock all sourcecode related extensions (.cs, .aspx, .mdf)
             and files/folders (web.config, \bin) -->
            <requestFiltering>
               <hiddenSegments>
                  <clear />
               </hiddenSegments>
               <fileExtensions>
                  <clear />
               </fileExtensions>
            </requestFiltering>
         </security>
         <!-- Remove all ASP.NET file extension associations.
           Only include this if you have the ASP.NET feature installed, 
           otherwise this produces an Invalid configuration error. -->
         <handlers>
            <clear />
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
         </handlers>
         <!-- Map all extensions to the same MIME type, so all files can be
           downloaded. -->
         <staticContent>
            <clear />
            <mimeMap fileExtension="*" mimeType="application/octet-stream" />
         </staticContent>
      </system.webServer>
   </location>
</configuration>

我已经从指南中找到的标签更改了 <directoryBrowse/> 标签,因为您可能不想允许列出目录内容。 {your-temp-directory} 自然是相对于 web.config 文件的。重新启动您的 Web 应用程序,您应该一切顺利。