【问题标题】:ASP.NET Core MVC Download request `FileResult` giving error on Azure app serviceASP.NET Core MVC 下载请求“FileResult”在 Azure 应用服务上给出错误
【发布时间】:2018-02-15 15:43:40
【问题描述】:

在 ASP.NET Core MVC 应用程序中,我尝试通过返回 FileResult 来下载文件

public FileResult Download()
{
    var fileName = $"DM.jpg";
    var filepath = $"download/{fileName}";
    byte[] fileBytes = System.IO.File.ReadAllBytes(filepath);
    return File(fileBytes, "application/x-msdownload", fileName);
}

它在 localhost 上运行良好,但是当我在 Azure 上发布应用程序时,它无法运行并显示“处理您的请求时发生错误”。 我怎么知道错误是什么?

【问题讨论】:

    标签: c# azure asp.net-core-mvc-2.0


    【解决方案1】:

    要解决此问题,请尝试:

    1.Turn off customErrors 获取有用的错误信息

    <configuration>
      <system.web>
        <customErrors mode="Off" />
      </system.web>
    </configuration>
    

    2.Enable diagnostics logging 用于您的 Azure 应用服务 Web 应用并检查日志。

    3.Remote Debug 在您的 asp.net 核心上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-07
      • 2012-06-03
      • 2020-10-12
      • 2017-05-10
      • 2020-11-15
      • 2019-03-24
      • 2010-12-18
      相关资源
      最近更新 更多