I am using Rotativa to generate Views as PDF and it runs/works perfectly on my localhost. However when deployed to either a shared host on GoDaddy or my Azure website instance I get the following error.
I attempted to grant permissions on .exe in the Rotativa folder with no luck, also tried running with Full Trust and still getting the error.
ERROR / STACKTRACE
Access is denied
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.ComponentModel.Win32Exception: Access is denied
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:
[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +1789 System.Diagnostics.Process.Start() +6735098
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) +226
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) +26 Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +128
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +52
1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
CONTROLLER
public ActionResult Print(Guid reportId)
{
var report = new ViewAsPdf("Index", new { id = reportId}) { FileName = "testReport.pdf" };
return report;
}
PERMISSIONS I tried to set permissions on the entire folder "Rotativa" with full control and now I get this...
This program is blocked by group policy. For more information, contact your system administrator
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.ComponentModel.Win32Exception: This program is blocked by group policy. For more information, contact your system administrator
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:
[Win32Exception (0x80004005): This program is blocked by group policy. For more information, contact your system administrator]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +1789 System.Diagnostics.Process.Start() +6735098
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) +226
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) +26 Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +128
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +52
1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
UPDATE JAN 13/2015
I ended up switching to TuesPechkin which has been a far easier solution to work with. GoDaddy does support FullTrust as does Azure, however Azure has a known issue with running processes that call into the GDI which most wkhtmltopdf libraries do. TuesPechkin didn't work on Azure either so I never found a solution for an Azure website, but TuesPechkin worked perfect on GoDaddy hosting with the set in my web.config.
Unable to load DLL 'wkhtmltox.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
error. Can you provide your code you used to define your converter? Did you use the nuget packages? Which package(s) did you use (32 or 64 bit)? Thanks for your help. I'm really stuck! – Jacob Hulsenew StaticDeployment(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources"))
is failing. Did you use TempFolder or StaticDeployment for your deployment class? – Jacob Hulsestatic IConverter converter = new ThreadSafeConverter(new RemotingToolset<PdfToolset>(new Win32EmbeddedDeployment(new TempFolderDeployment()))); public static byte[] GetPDF(HtmlToPdfDocument document) { return converter.Convert(document); }
also fails – Jacob Hulse