我使用罗塔蒂瓦来生成我的Razor视图的pdf。它在我的本地机器上运行良好,但是当我将我的站点发布到web主机并试图生成pdf时,我得到了以下错误:
控制器动作方法
//Generate and output the View pdf file
public ActionResult PDFCatalogue(int id)
{
var productList = db.ProductImages.Include("Products")
.Select(m => new ProductDisplayViewModel
{
ProductId = m.Id,
Name = m.Products.Name,
ImageUrl = m.URL,
Thumbnail = m.URL.Replace(".jpg", "-thumb.jpg"),
CategoryId = m.Products.CategoryId,
CategoryName = m.Products.Category.CategoryName,
Sizes=m.Products.Sizes
}).Where(i => i.CategoryId == id).OrderByDescending(m => m.ProductId).ToList();
TempData["CategoryName"] = db.Category.Where(m => m.Id == id).Select(k => k.CategoryName).SingleOrDefault();
if (productList == null)
{
return HttpNotFound();
}
return View("~/Views/Catalogue/PDFCatalogue.cshtml", productList);
//return new RazorPDF.PdfResult(productList, "~/Views/Catalogue/PDFCatalogue.cshtml");
//return new MvcRazorToPdf.PdfActionResult("~/Views/Catalogue/PDFCatalogue.cshtml", productList);
}
public ActionResult GeneratePDF(int id=0)
{
return new Rotativa.ActionAsPdf("PDFCatalogue", new { id = id });
}“/”应用程序中的服务器错误。未处理的执行错误描述:在执行当前web请求期间发生了未处理的异常。请查看堆栈跟踪以获得有关错误的更多信息,以及它起源于代码的位置。
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) +975
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches) +50
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) +96
Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +250
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +66
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +245
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +22
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +176
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +75
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
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() +9651796
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155P.S: Rotativa在应用程序根目录中创建一个Rotativa目录,它将wkhtmltopdf.exe设置为Rotativa目录的权限,以便对应用程序池用户进行完全控制
发布于 2015-10-27 13:14:02
我有一个类似的问题,并找到了这帖子,它在页面上写着用下面链接中的一个交换生产服务器上的.exe文件。这个解决了我的问题
以下是下载链接O3vUM1aEppb3ZVZXNSC 28/view
https://stackoverflow.com/questions/33158280
复制相似问题