【发布时间】:2016-09-16 13:16:15
【问题描述】:
我有一个方法,它根据从模型中检索到的信息从视图中创建一个 pdf 文件。它在我的电脑上以调试模式运行没有任何问题,但是在 IIS 服务器(不同的机器)上部署后它开始崩溃。 我已通过程序集授予地图上所有用户的完全访问权限,但没有帮助。 错误信息是无用的,它只是说“出了点问题”
说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
我的代码:
[HttpPost]
public ActionResult EmployeesForExamination(List<EmployeeListForHealthExamination> model)
{
List<EmployeeListForHealthExamination> listForPrint = new List<EmployeeListForHealthExamination>();
foreach (var item in model)
{
if (item.printDoc)
{
return CreatePDF(item);
}
}
return View(model);
}
[AllowAnonymous]
public ActionResult ReportForHE(EmployeeListForHealthExamination model)
{
using (var db = new HRMEntities())
{
model.harmingFactorList = db.EmployeeHarmingFactors.Where(e => e.EmployeeId == model.EmployeeId).ToList();
return PartialView("Partial/_ReportHE", model);
}
}
[AllowAnonymous]
public ActionResult CreatePDF(EmployeeListForHealthExamination model)
{
return new ActionAsPdf("ReportForHE", model)
{
FileName = model.FirstName + model.LastName + "HealthExamination.pdf"
};
}
【问题讨论】:
-
您可以访问查看堆栈跟踪/错误日志吗?这将为出现问题提供一些主要线索。
-
@nockieboy 是吗?
-
如果可以的话,从服务器上的命令行执行 wkhtmltopdf 以检查它是否可以在该机器上运行。它在哪里托管?你的服务器?天蓝色?虚拟主机?
-
此外,如果您选择使用 SaaS API,则可以完全解决这些问题。我为此设置了rotativahq.com。
-
@Vadim.K 我的意思是从命令行尝试。如果它不能从那里工作,那么服务器缺少某些东西,例如 GDI 库。
标签: c# asp.net-mvc pdf iis itext