andrewdavey / andrewdavey/postal
Email send fails when no HttpContext is available in ASP MVC application
- Linguagem predominante
- C#
- Estrelas
- 534
- Forks
- 164
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
Hello!
I'm using Postal in one of my personal projects and find it very useful! However recently I've encountered a minor issue which I think is a bug in current version (I've tried latest 0.9.2 release).
I want to use email views and models of ASP MVC web application in two different scenarios. First is widespread - to send email from controller action method by using `Email.Send()`. Second is more tricky and it lead to the issue - to send email from background thread by using same method `Email.Send()`.
Actual problem is `ArgumentException` occuring in `Email.Send()` and originating from `System.Web.CachedPathData.GetVirtualPathData()`. Issue manifests only if web application root doesn't match the web site root, e.g. web application is located at _http://mydomain.com/MyApp/_, not in _http://mydomain.com/_.
Problem source is in method `EmailViewRenderer.UrlRoot()`, where `System.Web.VirtualPathUtility` can be used to generate correct application root url if `HttpContext.Current` is undefined instead of simply return _http://localhost_.
Now I init `HttpContext.Current` manually before calling `Email.Send()` as a workaround.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.