Rotativa ActionAsPdf() Very Slow

时光毁灭记忆、已成空白 提交于 2020-01-02 07:02:41

问题


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

ActionAsPdf hangs randomly for indeterminate amount of time.

Code below that is hanging:

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

Background info that may help:

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.

Observations, usage and testing:

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.

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.

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.

Questions I have:

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


回答1:


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.



来源:https://stackoverflow.com/questions/32854225/rotativa-actionaspdf-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!