【发布时间】:2019-07-26 14:14:23
【问题描述】:
我正在尝试从 .Net Core Web Api 生成和下载一个 excel 文件。此 Web api 托管在 azure app services 中。使用 EpPlus 包生成的 Excel 文件。该文件通过传递日期范围和一些其他参数生成。文件的大小取决于日期范围。当我为日期范围文件下载提供 1 天没有问题时,因为文件的大小很小。当我给大日期范围服务器返回“500 - 请求超时”。
我尝试在 azure app service 上进行远程调试,只需要 2 分钟即可完成请求并返回响应。但它不会返回到网络浏览器
这是我的 web api 获取方法
[HttpGet]
public FileResult GetReport(String StartDate, String EndDate, bool SIH, bool FinalOrder, bool Allocations, Boolean GRN, bool ActualSale, bool Buffers, bool FillRate, bool Forecast)
{
//Generating exel file in to a byte[] using EpPlus package here
var memoryStream = new MemoryStream();
excel.SaveAs(memoryStream);
byte[] byteArray = memoryStream.ToArray();
memoryStream.Close();
const string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Response.ContentType = contentType;
HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
var fileContentResult = new FileContentResult(stream, contentType)
{
FileDownloadName = "Infor-Report.xlsx"
};
return fileContentResult;
}
这是我在 Azure 应用服务中的 web.config 文件
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\JMSL.OMS.BackEnd.API.dll" requestTimeout="00:20:00" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" forwardWindowsAuthToken="false">
<environmentVariables />
</aspNetCore>
还有我的program.cs
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = null;
})
.Build();
我在这里做错了什么?非常感谢您的反馈。提前致谢
【问题讨论】:
标签: asp.net-core iis .net-core azure-web-app-service asp.net-core-webapi