When faced with a similar issue, I discovered that Rotiva was not retrieving all my included files or was taking too long to do so.
To resolve this, I identified essential elements and constructed a "static layout" that encompassed all necessary components inline. This could involve CSS files required for proper rendering or included JavaScript files. By manually adding the contents of these files into style or script tags within the Static Layout, Rotativa could access these payloads without additional retrieval.
//Static Layout
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<meta charset="utf-8" />
<style type="text/css">
body {
color: white;
}
/*Any necessary style information*/
</style>
<script type="text/javascript">
/*Any required code*/
</script>
</head>
<body>
<div class="container">
@RenderBody()
</div>
</body>
</html>
I implemented this Layout as a replacement for my standard Layout specifically for the Rotativa exporting views.
Subsequently, I duplicated the view for Rotativa PDF output, utilizing this static layout.
@model SomeModel
@{
ViewBag.Title = "Some Title";
Layout = "~/Views/Shared/_LayoutStatic.cshtml";
}