Rotativa: Exception when deployed to server
Apologies if I’m being slow - I’ve incorporated Rotativa and it works on my dev machine but when I try to use it on the server I receive the below:
Server Error in ‘/’ Application.
Unhandled Execution Error Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception:
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Exception]
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) +822
Rotativa.ViewAsPdf.CallTheDriver(ControllerContext context) +1027
Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +201
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +27
Castle.Proxies.ControllerActionInvokerProxy.InvokeActionResult_callback(ControllerContext controllerContext, ActionResult actionResult) +21
Castle.DynamicProxy.AbstractInvocation.Proceed() +69
Glimpse.Mvc3.Interceptor.InvokeActionResultInterceptor.Intercept(IInvocation invocation) +431
Castle.DynamicProxy.AbstractInvocation.Proceed() +204
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +263
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +729
System.Web.Mvc.Controller.ExecuteCore() +162
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +159
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1656
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +540
Server is Server 2008 R2 and application is dotNet 4.5
Call to Rotativa is
return new ViewAsPdf(“View”, “~/Views/StaffExpenses/_ViewLayout.cshtml”, claim) { PageSize = Size.A4, PageOrientation = Orientation.Landscape, PageMargins = {Left = 0, Right = 0, Top = 0, Bottom = 0} };
Both Authenticated Users and the app pool have execute permissions on the files in the Rotativa folder which has deployed to the server with the application.
Project uses Windows Authentication
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 93 (15 by maintainers)
Worked for me.
Thank You
claudiomaia commented on 4 Apr 2015 Para quem utiliza Asp.Net.MVC, volte a versão para 1.6.1 do rotativa que irá funcionar no servidor. Foi a solução que encontrei para resolver o problema (pelo menos por enquanto)
For those who use Asp.Net.MVC update in nuget to 1.6.1 of Rotativa that will work on the server. It was the solution I found to solve the problem (at least for now).
Eu corrigi esse bug, fiz o download pelo nuget do pacote Rotativa PDF no Visual Studio normalmente, na minha máquina era a versão 64 bits. Quando fui publicar no servidor, baixei no site oficial http://wkhtmltopdf.org a versão 32 bits do aplicativo wkhtmltopdf, depois peguei apenas a versão 32 bits do executável e substitui na pasta Rotativa. Funcionou que é uma beleza!
I upgraded the Rotativa nuget package to 1.6.4. After that I started getting these errors on the server, but not locally: System.Exception at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches) at Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) at Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context)
I downloaded the newest version of wkhtmltopdf.exe and replaced the one in the project’s Rotativa folder, and now the PDF generation works as expected.
@janessaallen grab the installer here. Once it’s installed grab the files from /program files/wkhtmltopdf/bin/ and put those in ~/rotativa/
Para quem utiliza Asp.Net.MVC, volte a versão para 1.6.1 do rotativa que irá funcionar no servidor. Foi a solução que encontrei para resolver o problema (pelo menos por enquanto)
For those who use Asp.Net.MVC update in nuget to 1.6.1 of Rotativa that will work on the server. It was the solution I found to solve the problem (at least for now).
@mortenholmgaard UrlAsPdf will use the hostname contained in the http request and if that name is not resolved on the server then you have a problem. You could login to the server machine and try name resolution there.