andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 168 forks source link

The virtual path '/' maps to another application, which is not allowed. #65

Closed remcoros closed 10 years ago

remcoros commented 10 years ago

Just starting to use this library I get this exception when trying to send a basic email using Asp.Net MVC 5:

Nothing fancy, Just followed the instructions on the website. I am running my application as http://localhost/sitename

[ArgumentException: The virtual path '/' maps to another application, which is not allowed.]
   System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) +12796283
   System.Web.HttpContext.GetFilePathData() +60
   System.Web.HttpContext.GetRuntimeConfig() +38
   System.Web.HttpRequest.get_Browser() +191
   System.Web.HttpRequestWrapper.get_Browser() +18
   System.Web.WebPages.BrowserHelpers.GetOverriddenBrowser(HttpContextBase httpContext, Func`2 createBrowser) +360
   System.Web.WebPages.DisplayModeProvider.<.ctor>b__2(HttpContextBase context) +11
   System.Web.WebPages.<GetAvailableDisplayModesForContext>d__4.MoveNext() +192
   System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +856
   System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +206
   System.Web.Mvc.<>c__DisplayClass6.<FindView>b__4(IViewEngine e) +43
   System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +174
   System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator) +23
   Postal.EmailViewRenderer.Render(Email email, String viewName) +63
   Postal.EmailService.Send(Email email) +58
   UHearth.Web.Controllers.<>c__DisplayClass16.<SendEmailConfirmation>b__15() in c:\Users\Remco\Documents\Visual Studio 2013\Projects\HearthstoneTracker.com\UHearth.Web\Controllers\AccountController.cs:186
remcoros commented 10 years ago

Never mind. HttpContext.Current is null when sending email in a background thread. I will need to handle this differently.