iis-7 - Rotativa PDF生成在本地运行,但不能在IIS 7上运行

标签 iis-7 asp.net-mvc-5 rotativa

我有一个ASP.NET MVC 5应用程序。它具有一个简单的表单,当用户提交表单时,该表单将存储在缓存中,然后调用另一个 Controller 操作,该操作会将模型作为 View 返回为PDF。

我无需将其保存在本地,只需将其显示在浏览器中即可让用户下载。

也不需要数据库,这就是为什么我将模型存储在缓存中。

在本地,在Visual Studio 2013上运行正常。但是,当我将其发布到IIS 7时,我得到了Unhandled Execution Error。这是我返回的堆栈跟踪:

 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 

我首先使用ActionAsPDF(),但现在我也尝试使用return new ViewAsPDF()。两者都给出相同的错误和堆栈跟踪。这是否需要做一些许可?

最佳答案

此错误是缺少的名为(MSVCP120.dll)的Visual Studio 2013文件的C++可再发行程序包。

解决问题:

  • 打开下面的Visual Studio 2013 C++可再发行组件包可下载链接:
    download Visual C++ Redistributable Packages for Visual Studio 2013
  • 单击“下载”并选择文件(vcredist_x86.exe),即使您正在运行X64位服务器版本。
  • 安装文件。

  • 有关更多详细信息,请查看Jalal W Hijazi博客http://jwhijazi.blogspot.com/2015/05/solving-rotativa-unhandled-exception.html

    关于iis-7 - Rotativa PDF生成在本地运行,但不能在IIS 7上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31112349/

    相关文章:

    asp.net-mvc-3 - IIS 7.5 和 MVC 3 使用 Windows 身份验证 - 为静态内容获取 401,但永远不会提示输入凭据

    c# - 使用 Rotativa 从多个 View 生成 pdf?

    iis-7 - 如何在 URL 重写 w/ARR 的出站规则中获取反向代理服务器的 HTTP_HOST

    windows - WebResource.axd 使用 IIS7 在 ASP.Net Post 中给出 403 错误

    asp.net - MVC + IIS7 = CSS 问题

    asp.net - 如何在 ASP.net MVC 应用程序中隔离用户数据?

    c# - SqlDataReader 与数据集

    asp.net - 自定义错误消息 MVC

    asp.net-mvc-5 - 为什么 Rotativa 总是生成我的登录页面?为什么慢?