chris
chris

Reputation: 561

rotativa not serving header or footer on SSL

I am using

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

which works great locally and on Test but as soon as I put it on live (with SSL) it falls over with the following error:-

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)

any idea why the header and footer will not render on live? when I do navigate to the header and footer via the browser they render on the page.

Upvotes: 1

Views: 1644

Answers (2)

Chen Chen
Chen Chen

Reputation: 182

I think it's an internal issue with Rotativa. However, this is a way my colleague has come up with as a work around.

On your server, go to C:\Windows\System32\drivers\etc

Open file 'hosts'

Add your server IP followed by your host name. For example: 127.0.0.1 www.stackoverflow.com

Upvotes: 2

progproger
progproger

Reputation: 988

You have to add the following dll's in your web app to "Rotativa" folder: (I guess, you already have it with "wkhtmltopdf.exe" file)

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

These files are located in "C:\Windows\SysWOW64".

Upvotes: 0

Related Questions