Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ViewAsPdf.cs #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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)
}
}
}
}
}