andrewdavey / andrewdavey/postal

Email send fails when no HttpContext is available in ASP MVC application

Aberta
#73 3 comentários 0 reações 0 responsáveis Ver no GitHub
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.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.