Skip to content

Instantly share code, notes, and snippets.

@tuespetre
Created October 11, 2014 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuespetre/f333b6bba4f9a8b496bc to your computer and use it in GitHub Desktop.
Save tuespetre/f333b6bba4f9a8b496bc to your computer and use it in GitHub Desktop.
Postal.Mvc5 HttpContext workaround (issue #73)
// Workaround for Postal.MVC5 1.2.0 issue 73
// https://github.com/andrewdavey/postal/issues/73
if (HttpContext.Current == null)
{
var baseURL = ConfigurationManager.AppSettings["baseURL"].TrimEnd('/');
var absolute = VirtualPathUtility.ToAbsolute("~/").TrimStart('/');
HttpContext.Current = new HttpContext(
new HttpRequest("", baseURL + "/" + absolute, ""),
new HttpResponse(new StringWriter())
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment