andrewdavey / andrewdavey/postal
Email send fails when no HttpContext is available in ASP MVC application
- Lingua principale
- C#
- Stelle
- 534
- Fork
- 164
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.