Rotativa PDF generation working locally but not on IIS 7

rotativa not working on production
rotativa html string to pdf
the system cannot find the file specified rotativa
rotativa not working on shared hosting
rotativa access is denied
print pdf using rotativa
how to use rotativa in mvc 5
actionaspdf not working

I have an ASP.NET MVC 5 application. It has a simple form and when the user submits it, the form is stored in the cache and then another controller action is called, this action will return the model as a view as a PDF.

I have no need to save it locally, just to show it in the browser so that the user can download it.

There is no need for a database either, that is why I store the model in the cache.

Locally, on Visual studio 2013, it works fine. But when I publish it to IIS 7 I get an Unhandled Execution Error. Here is the stack trace that I get back:

 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) +1364
   Rotativa.WkhtmltopdfDriver.ConvertHtml(String wkhtmltopdfPath, String switches, String html) +70
   Rotativa.ViewAsPdf.CallTheDriver(ControllerContext context) +1986
   Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +380
   Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +69
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248 

I first used ActionAsPDF() but now I also tried to use return new ViewAsPDF(). Both give the same error and stack trace. Does this have to do something with permissions?

This error is a missing C++ redistributable Package for Visual Studio 2013 file called (MSVCP120.dll).

To solve the issue:

  1. Open the C++ redistributable Package for Visual Studio 2013 downloadable link below: download Visual C++ Redistributable Packages for Visual Studio 2013

  2. Click Download and choose the file (vcredist_x86.exe) even if you are running X64 bit server version.

  3. Install the file.

Check Jalal W Hijazi Blog http://jwhijazi.blogspot.com/2015/05/solving-rotativa-unhandled-exception.html for more details.

iis 7, This error is a missing C++ redistributable Package for Visual Studio 2013 file called (MSVCP120.dll). To solve the issue: Open the C++ redistributable Package  Rotativa PDF generation working locally but not on IIS 7 (6) . I have an ASP.NET MVC 5 application. It has a simple form and when the user submits it, the form is stored in the cache and then another controller action is called, this action will return the model as a view as a PDF.

As mentioned in the comments on the blog linked in the answer, you can just copy the 2 following dll files to the rotativa folder on the server if you don't want to / can't easily install things on the server.

msvcr120.dll msvcp120.dll

If it's working locally, you should have the two dll files available already. You need the x86 versions, if you find x64 versions packaged with vs 2015 they don't work. I found the right versions here:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT

After upgrading to Rotativa 1.7.3 this no longer worked. I had to copy over some new dlls from visual studio 2017, i found them here this time:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT

and i had to copy over

msvcp140.dll vcruntime140.dll

Error Rotativa pdf creator works locally but not in the server in mvc4 , I have an ASP.NET MVC 5 application. It has a simple form and when the user submits it, the form is stored in the cache and then another controller action is  iis 7 - Rotativa PDF generation working locally but not on IIS 7 asp.net mvc - How to set background image in Rotativa PDF generation tool asp.net mvc - Watermark in Pdf using css or Rotativa (PDF generater)

The accepted answer almost worked for me. I was missing a newer version of the C++ redistributable so installing the old version didn't help.

The easiest way to find out what you are missing is to run wkhtmltopdf.exe manually. It will either give you console output (if working) or a message box about what's missing.

I was missing MSVCP140.dll, which is from the VS 2015 redist, available here: https://www.microsoft.com/en-gb/download/details.aspx?id=48145

Rotativa PDF generation working locally but not on IIS 7, Buen día. Yo solucioné ese error copiando la carpeta Rotativa (que se crea cuando instalas el paquete en tu proyecto visual studio) hacia la  iis windows authentication is missing at windows 10(ASP.NET Visual Studio 2015) Deploy angular application on IIS ; Rotativa PDF generation working locally but not on IIS 7 ; applicationhost.config file path in IIS 7, 7.5, 8, 8.5 and IIS 10?

I fixed my issue by updating the wkhtmltopdf files from the installer found here

Working flawlessly now!

MVC Rotativa PDF IIS Server Error, Rotativa PDF generation working locally but not on IIS 7. Question. I have an ASP​.NET MVC 5 application. It has a simple form and when the user submits it, the  Step 4: This is the final stage you have to only place those dll inside the Rotativa folder which you are hosted in the IIS . If you are enable to execute the Visual C++ Redistributable Packages in production server, no need to worry, Only just placed "MSVCP120.dll" inside the Rotative folder.

When I upgraded from Rotativa 1.6.4 to 1.7.3 my PDF conversion on my website app stopped working and after running the wkhtmltopdf.exe on my production server I noticed it was having an issue with msvcp140.dll

Solution was to install Visual C++ Redistributable for Visual Studio 2015 https://www.microsoft.com/en-us/download/details.aspx?id=48145

MVC5 application with Rotativa does not work when published on IIS, Once you try to work to generate the PDF using Rotativa, you may face the error Information regarding the origin and location of the exception can be C++ Redistributable Packages in production server, no need to worry,  I am using Rotativa to generate a pdf from a view I have created. Locally this works fine, the pdf is stored on my local computer and the email functiont then attaches and sends the file. But when I release it on our server, it basically breaks at this part:

Exception when deployed to server · Issue #23 · webgio/Rotativa , After doing some research here is what I found that resolved the Rotativa not working on server issue for me: The wkhtmltopdk.exe used by Rotativa to generate  Rotativa PDF generation fonctionne localement mais pas sur IIS 7 j'ai un ASP.NET MVC 5 application. Il a une forme simple et quand l'utilisateur la soumet, la forme est stockée dans le cache et alors une autre action de controller est appelée, cette action retournera le model comme une vue en PDF.

Rotativa pdf, Apologies if I'm being slow - I've incorporated Rotativa and it works on my dev machine IIS 7.5. The executable of 7 day ago, size 8364kb gives the error After that I started getting these errors on the server, but not locally: in the project's Rotativa folder, and now the PDF generation works as expected. following code is working fine on my local machine: return new Rotativa.ViewAsPdf("Order", all) { FileName = "Sample.pdf" }; I tried the steps mentioned in Rotativa PDF generation working locally but not on IIS 7 , but didn't help.

Rotativa pdf does not work on server - asp.net-mvc - iOS, PDF generation working locally but not on IIS 7 [Resolved] I have an ASP. Rotativa makes it very easy to generate pdf from an HTML. 1 de Rotativa via NuGet. Lower Case Dashed Route Working with Rotativa PDF PDF Export using Rotativa in Azure Cloud Service - Issues with non Latin Character Sets Rotativa PDF generation working locally but not on IIS 7

Comments
  • Is it really throwing System.Exception and not some derived class? That would be extremely poor.
  • This is all that I'm getting back and since I can not duplicate it locally I don't know how to debug through it.
  • The first line of the stack however has a parameter that sounds like it is a path name, I had troubles with paths and IIS before, could this be an issue?
  • Maybe the VC++ redist is missing on the server as indicated here
  • Thank you this solved the problem indeed!
  • Tip (on the Jalal blog) that worked for me: "I just copied msvcp120.dll and msvcr120.dll to the folder containing wkhtmltopdf.exe and all worked fine"
  • @HugoXP you should write this as a seperate answer - awesome!
  • Current Rotativa requires Visual C++ for Visual Studio 2015
  • C++ Redistributable 2013 no longer works, I had to install Microsoft Visual C++ Redistributable for Visual Studio 2017 (support.microsoft.com/en-my/help/2977003/…) for it to work.
  • This worked for me. On the server, I tried including the x64 dlls. However, they were not fixing the issue. So switched to x86 dlls and they worked liek a charm. Thanks a lot.
  • In case anyone else runs into this issue, at this point (June 2019), I also needed to install this and discovered that you must install the x86 version. Installing just the x64 version does not work.
  • Oh..and this running on a azure hosted machine.. Sever 2012 VM not locally on my laptop
  • The same thing happened to me after upgrading to 1.7.3. Installing the x86 vs 2015 redistributable fixed it.