Open jmsolutionsgroup opened 8 years ago
I want to clarify my issue. I am utilizing Hangfire to send emails in the background. I have followed the tutorial located http://docs.hangfire.io/en/latest/tutorials/send-email.html. When I have IISExpress configured to debug the site on http://localhost:7706 everything works correctly. When I have IISExpress configured to debug the site on http://localhost:7706/SubSite I receive the error
The virtual path '/' maps to another application, which is not allowed
I have tracked the error down to the following line in the EmailViewRenderer.cs file
var result = viewEngines.FindView(controllerContext, viewName, null);
of
IView CreateView(string viewName, ControllerContext controllerContext)
{
var result = viewEngines.FindView(controllerContext, viewName, null);
if (result.View != null)
return result.View;
throw new Exception(
"Email view not found for " + viewName +
". Locations searched:" + Environment.NewLine +
string.Join(Environment.NewLine, result.SearchedLocations)
);
}
I found that the issue was that the controllerContext httpContext was not getting set correctly. In the method
string UrlRoot()
{
var httpContext = HttpContext.Current;
if (httpContext == null)
{
return "http://localhost";
}
return httpContext.Request.Url.GetLeftPart(UriPartial.Authority) +
httpContext.Request.ApplicationPath;
}
if the httpContext is null which is the case when using hangfire the default value is "http://localhost"
If I changed the default value to be "http://localhost/SubSite" then everything will work without an issue. Is there a configuration that I can set to get this to work without modifying the source code?
I'm having the same issue. Is there any solution that does not involve modifying the source code??
I was able to resolve my issue, I had previously posted on stackoverflow. Here is the link to my issue and resolution. http://stackoverflow.com/questions/35389505/using-postal-and-hangfire-in-subsite
@uchetfield Thanks!
@mauricioulloa FYI I updated my answer on stackoverflow with a more elegant solution that also resolved some other issues that appeared once my application was a heavy stress.
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. If I change my url to be http://localhost/ the email works without an issue This is the same issue as https://github.com/andrewdavey/postal/issues/65
[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>b2(HttpContextBase context) +11 System.Web.WebPages.2 lookup, Boolean trackSearchedPaths) +174 System.Web.Mvc.ViewEngineCollection.Find(Func
2 cacheLocator, Func2 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