我正在使用
string customSwitches = string.Format("--header-html \"{0}\" " +
"--header-spacing \"0\" " +
"--footer-html \"{1}\" " +
"--footer-spacing \"10\" " +
"--footer-font-size \"10\" " +
"--header-font-size \"10\" , Url.Action("xxx", "xxxx", new { hid = xxxx.ID }, httType), Url.Action("Footer", "xxxxx", new { hid = xxxxx.ID }, httType ));
var actionResult = new Rotativa.ViewAsPdf("Letter")
{
FileName = gid.ToString(),
CustomSwitches = customSwitches
};这在本地和测试上都很好用,但当我把它放到live (使用SSL)时,它就会出现以下错误:-
System.Exception:
Error: Failed loading page https://xxxxxxxxx/xxxxxxxx/header?hid=0 (sometimes it will work just to ignore this error with --load-error-handling ignore) Error: Failed loading page https://134.213.201.226/Discharge/Footer?hid=0 (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: UnknownNetworkError
System.Exception: Error: Failed loading page https://xxxxxxx/xxxxxxxx/header?hid=0 (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed loading page https://xxxxxxxxxx/xxxxxxxxx/Footer?hid=0 (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: UnknownNetworkError
at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html)
at Rotativa.WkhtmltopdfDriver.ConvertHtml(String wkhtmltopdfPath, String switches, String html)
at Rotativa.ViewAsPdf.CallTheDriver(ControllerContext context)
at Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context)你知道为什么页眉和页脚不能实时渲染吗?当我这样做时,通过浏览器导航到页眉和页脚,它们呈现在页面上。
发布于 2017-04-05 19:10:31
我认为这是Rotativa的内部问题。然而,这是我的同事想出的一种变通办法。
在服务器上,转到C:\Windows\System32\drivers\etc
打开文件'hosts‘
添加服务器IP,后跟主机名。例如: 127.0.0.1 www.stackoverflow.com
发布于 2017-03-16 22:53:59
你必须在你的web应用程序中添加以下动态链接库到"Rotativa“文件夹:(我想,你已经有了"wkhtmltopdf.exe”文件)
msvcp120.dll,msvcr120.dll,vccorlib120.dll。
这些文件位于"C:\Windows\SysWOW64“。
https://stackoverflow.com/questions/37809453
复制相似问题