我正在尝试让 IronPDF 参与我的 ASP.NET Core 3.1 应用服务部署。我没有使用 Azure Functions 来实现这些目的,而只是使用 Azure 应用服务上的常规端点 - 当用户调用它时,该服务会生成并返回生成的 PDF 文档。
在本地主机上运行端点时,它可以完美地工作 - 从传递到方法中的 HTML 生成报告。但是,一旦我将其部署到 Azure Web App Service,我就会收到502 - Bad Gateway错误,如附件所示(为了整洁起见,在 Swagger 中显示)。
控制器:
[HttpPost]
[Route("[action]")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> AgencyDownload([FromBody] AgencyReportSubmissionDto filters)
{
var user = await _userService.GetUserByIdAsync(HttpContext.User.GetUserId());
// Generate the PDF
var content = await _agencyReport.Generate(user, null, filters.FilterDate, filters.Content, filters.Type);
// Return the PDF to the browser
return new FileContentResult(content.BinaryData, "application/pdf") { FileDownloadName = "report.pdf" };
}
Run Code Online (Sandbox Code Playgroud)
服务:
public …Run Code Online (Sandbox Code Playgroud)