Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Rotativa/ViewAsPdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ protected override byte[] CallTheDriver(ControllerContext context)
StringBuilder html = sw.GetStringBuilder();

// replace href and src attributes with full URLs
string baseUrl = string.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority);
// string baseUrl = string.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority);
// Use the original HttpContext from the passed in ControllerContext. In some situations the HttpContext is null. An async (awaited) DI injected service with Ninject lost his HttpContext.
string baseUrl = string.Format("{0}://{1}", context.HttpContext.Request.Url.Scheme, context.HttpContext.Request.Url.Authority);
html.Replace(" href=\"/", string.Format(" href=\"{0}/", baseUrl));
html.Replace(" src=\"/", string.Format(" src=\"{0}/", baseUrl));

Expand All @@ -110,4 +112,4 @@ protected override byte[] CallTheDriver(ControllerContext context)
}
}
}
}
}