Rotativa ActionAsPdf() 非常慢 [英] Rotativa ActionAsPdf() Very Slow

查看:32
本文介绍了Rotativa ActionAsPdf() 非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 NuGet 的 Rotativa 1.6.4 并使用以下代码注意到以下问题.

Using Rotativa 1.6.4 from NuGet and have noticed the following issue using the code below.

ActionAsPdf 随机挂起不确定的时间.

ActionAsPdf hangs randomly for indeterminate amount of time.

下面挂起的代码:

   var pdfResult = new ActionAsPdf("Report", new {id = Request.Params["id"]})
    {
        Cookies = cookieCollection,
        FormsAuthenticationCookieName = FormsAuthentication.FormsCookieName,
        CustomSwitches = "--load-error-handling ignore"
    };

可能有帮助的背景信息:

customSwitches 用于忽略使用 ActionAsPdf 调用 wkhtmltopdf.exe 的记录问题,但它不会仅在 wkhtmltopdf 调用中抑制代码中的错误.

The customSwitches is in use to ignore a documented issue calling wkhtmltopdf.exe using the ActionAsPdf, but it does not suppress errors in the code only in the wkhtmltopdf call.

观察、使用和测试:

它可以工作,但是在运行应用程序时(无论是否单步执行代码),在点击 pdfResult = new ActionAsPdf 和最终进入被调用的报告"操作之间可能需要 10 秒到大约 4 分钟的时间.无法辨别 Visual Studio 的输出窗口中实际发生的任何事情,我发现没有抛出任何错误.只是随机缓慢过渡到 Reports() 动作.

It works but when running the application (whether or not stepping through code), it can be anywhere from 10 seconds up to about 4 minutes between hitting the pdfResult = new ActionAsPdf and finally entering into the "Report" action being called. Can't discern anything actually happening in the output window of Visual Studio, no errors are being thrown that I have found. Just random slow transition into the Reports() action.

我可以直接通过 URL 运行 Reports() 操作,它永远不会像这样变慢,而且生成 PDF 的速度非常快.我正在使用 ActionAsPdf 运行它以获取二进制文件以保存到文件系统并通过电子邮件发送,这是该库的规定方法.

I can run the Reports() action directly via URL and it never slows like this and is quite fast for PDF generation. I am running it using the ActionAsPdf to obtain the binary to save to file system and send via email, which is the prescribed method of doing so for this library.

该行为存在于本地 Windows 10 开发设备和远程 Server 2008R2 测试设备上.两个机器上的 .Net 4.5.1,每个上的默认 IIS.

The behavior exists on both a local Windows 10 dev box and a remote Server 2008R2 Test box. .Net 4.5.1 on both boxes, default IIS on each.

我的问题:

知道是什么原因导致速度变慢以及如何补救吗?

Any idea on what might cause this slow down and how to remedy it?

推荐答案

我最终使用 UrlAsPdf() 而不是 ActionAsPdf() 并且它有效.似乎 ActionAsPdf() 可能存在一些问题,我已经在 GitHub 上的 Rotative 项目中提交了一个错误.ActionAsPdf() 仍标记为测试版,因此希望它在未来版本或社区中得到修复.

I ended up using UrlAsPdf() instead of ActionAsPdf() and it works. Seems there may be some issues with the ActionAsPdf() and I have filed a bug with Rotative project on GitHub. The ActionAsPdf() is still marked as beta, so hopefully it get's fixed in future versions or by the community.

这篇关于Rotativa ActionAsPdf() 非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆