rotativa不在SSL上提供页眉或页脚

时间:2016-06-14 10:29:32

标签: html asp.net-mvc ssl wkhtmltopdf rotativa

我正在使用

        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
        };

在本地和测试中运行良好,但是一旦我将它置于实时(使用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)

任何想法为什么页眉和页脚不会在现场呈现?当我通过他们在页面上呈现的浏览器导航到页眉和页脚时。

2 个答案:

答案 0 :(得分:1)

我认为这是Rotativa的内部问题。然而,这是我的同事提出的一种解决方法。

在您的服务器上,转到C:\ Windows \ System32 \ drivers \ etc

打开文件' hosts'

添加您的服务器IP,然后添加您的主机名。例如:127.0.0.1 www.stackoverflow.com

答案 1 :(得分:0)

您必须在Web应用中将以下dll添加到“Rotativa”文件夹: (我猜你已经用“wkhtmltopdf.exe”文件了)

msvcp120.dll, msvcr120.dll, vccorlib120.dll。

这些文件位于“C:\ Windows \ SysWOW64”。