This project has moved and is read-only. For the latest updates, please go here.

Error sending email

Jan 14, 2012 at 5:21 PM

Hello,

TicketDesk works when run from VS2010 but when a published the project on IIS7 server I get the following error:

System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System.ArgumentException: The virtual path '/' maps to another application, which is not allowed.
   at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
   at System.Web.HttpContext.GetFilePathData()
   at System.Web.Configuration.HttpCapabilitiesBase.GetBrowserCapabilities(HttpRequest request)
   at System.Web.HttpRequest.get_Browser()
   at System.Web.UI.Page.SetIntrinsics(HttpContext context, Boolean allowAsync)
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.Mvc.ViewPage.ProcessRequest(HttpContext context)
   at System.Web.Mvc.ViewUserControl.ViewUserControlContainerPage.ProcessRequest(HttpContext context)
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
   at System.Web.Mvc.ViewUserControl.RenderViewAndRestoreContentType(ViewPage containerPage, ViewContext viewContext)
   at System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
   at TicketDesk.Web.Client.Areas.Admin.Controllers.EmailTemplateController.GenerateTicketNotificationEmailBody(TicketEventNotification notification, Int32 firstUnsentCommentId, String templateToRender) in D:\MyVsProjects\ticketdesk-source\TicketDesk_8af231a1f1ce\TicketDesk-2-branch\TicketDesk.Web.Client\Areas\Admin\Controllers\EmailTemplateController.cs:line 213
   at TicketDesk.Web.Client.Areas.Admin.Controllers.EmailTemplateController.GenerateTicketNotificationHtmlEmailBody(TicketEventNotification notification, Int32 firstUnsentCommentId) in D:\MyVsProjects\ticketdesk-source\TicketDesk_8af231a1f1ce\TicketDesk-2-branch\TicketDesk.Web.Client\Areas\Admin\Controllers\EmailTemplateController.cs:line 179
   at TicketDesk.Web.Client.MefManager.TicketNotificationHtmlEmailContent(TicketEventNotification notification, Int32 firstUnsentCommentId) in D:\MyVsProjects\ticketdesk-source\TicketDesk_8af231a1f1ce\TicketDesk-2-branch\TicketDesk.Web.Client\Mef\MefManager.cs:line 72
   at TicketDesk.Domain.Services.NotificationSendingService.GetHtmlBody(TicketEventNotification note, String notifyUser, Int32 minComment) in D:\MyVsProjects\ticketdesk-source\TicketDesk_8af231a1f1ce\TicketDesk-2-branch\TicketDesk.Domain\Services\NotificationSendingService.cs:line 366
   at TicketDesk.Domain.Services.NotificationSendingService.DeliverTicketEventNotificationEmail(TicketEventNotification note, List`1 consolidations) in D:\MyVsProjects\ticketdesk-source\TicketDesk_8af231a1f1ce\TicketDesk-2-branch\TicketDesk.Domain\Services\NotificationSendingService.cs:line 289

Do you have any idea why this is happening?

 

Jan 16, 2012 at 9:34 PM

<label for="Site Root Url For Email">Make sure you've set the "<label for="Site Root Url For Email">Site Root Url For Email" setting to an appropriate value in administration => Change Application Settings</label></label>

<label for="Site Root Url For Email"><label for="Site Root Url For Email">
</label>I can tell what is happening from the stack trace, but I'm not sure why or exactly where. I can tell you are most likely runnin in a virtual directory. When rendering the view that generates an EMAIL, the view subsystem is trying to map to a path that belongs to another IIS application. The problem is that some part of the email controller's attempt to render that view is causing the a subsystem to map a URL to a path outside the TicketDesk applicaiton. It's basically running into a security feature of asp.net that keeps one application from generating URLs that lead to content within a different application's hosted on the same server. </label>

 

I have not encountered this problem myself, but then again I also haven't run ticketdesk in a virtual directory often either. I'll see about getting time to do some testing on a virtual directory setup if the that admin setting isn't the issue. Just let me know.

 

Jan 17, 2012 at 9:20 PM

 

I found that the error was caused by the following line:

private string GenerateTicketNotificationEmailBody(TicketEventNotification notification, int firstUnsentCommentId, string templateToRender)

{

………………….

var fakeContext = new HttpContext(new HttpRequest("", "http://WINSRV/TicketDesk", ""), fakeResponse);

 …………………………

 }

When I changed the url from http://anywherefake.com/to my “http://server/applicationName” it worked.

 

Jan 18, 2012 at 10:11 PM
Seems like the best general purpose solution then would be to change it to where it maps a real(ish) path.

This is kicked off from a timer running on a background thread, so we can't easily build a valid real URL (no request object to use as a guide, and security doesn't usually allow you to query for the real network bindings from IIS). So the best solution is probably to just use the email root URL setting to build the fake context object up. I liked using a completely fake URL for the context object since it isn't actually used for any network I/O , but it seems the context object is tied to some aggressive back-end security.

I've pushed a change to source where this will use the same value from the app settings, which should work even in virtual directory cases.

All it does is change that line to this:
var fakeContext = new HttpContext(new HttpRequest("", AppSettings.SiteRootUrlForEmail, ""), fakeResponse);

I'd appreciate it if you could double check the fix, but it has passed live fire testing on my company's production servers.

Thanks,

Stephen M. Redd
redds@reddnet.net
http://reddnet.net



On Tue, Jan 17, 2012 at 4:20 PM, gabihodoroaga <notifications@codeplex.com> wrote:
fakeContext

Feb 14, 2013 at 3:35 PM
Hello,

I too have had this problem and have not been succesful with the new fix

System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System.ArgumentException: The virtual path '/Our%20Support%20System/' maps to another application, which is not allowed.
at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
at System.Web.HttpContext.GetFilePathData()
at System.Web.Configuration.HttpCapabilitiesBase.GetBrowserCapabilities(HttpRequest request)
at System.Web.HttpRequest.get_Browser()
at System.Web.UI.Page.SetIntrinsics(HttpContext context, Boolean allowAsync)
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.Mvc.ViewPage.ProcessRequest(HttpContext context)
at System.Web.Mvc.ViewUserControl.ViewUserControlContainerPage.ProcessRequest(HttpContext context)
at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func1 func)
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
at System.Web.Mvc.ViewUserControl.RenderViewAndRestoreContentType(ViewPage containerPage, ViewContext viewContext)
at MX.SupportSystem.Web.Client.Areas.Admin.Controllers.EmailTemplateController.GenerateTicketNotificationEmailBody(TicketEventNotification notification, Int32 firstUnsentCommentId, String templateToRender)
at MX.SupportSystem.Domain.Services.NotificationSendingService.DeliverTicketEventNotificationEmail(TicketEventNotification note, List
1 consolidations)

Thanks
Feb 15, 2013 at 12:26 AM
kev148, can you confirm that the appSetting in web.config for "SiteRootUrlForEmail" is correct for your production environment?
Feb 15, 2013 at 1:55 PM
I though it was but on a fresh look it wasn't. However once i corrected that and the emails were sent i encountered a new issue. The generted path for the images used in the email was incorrect.


For example with a "SiteRootUrlForEmail" of "http://localhost/Ticketdesk" instead of generating "localhost/Ticketdesk/Content/someimage.jpeg" the html generated a path "localhost/Ticketdesk/Ticketdesk/Content/someimage.jpeg"

Thanks for replying to my first post so promptly.
Kevin
Feb 19, 2013 at 8:07 PM
OK, I have reviewed the reports here, as well as the code. I have been unable to reproduce problems sending emails, nor with the image path with the latest code. I have tested on IIS 7, and IIS Express 8 with root sites as well as virtual directories.

I do want to clarify a few things.
  • The URLS for images require an application setting called "Site Root Url For Email". This value is configured in the administration section ticketdesk in the Application Settings tool (~/ApplicationSettings).
  • The value of this setting should include ONLY the protocol, host name, and port. You should not include the virtual directory. E.g. "http://localhost", or "http://localhost:2534", but __NOT__ "http://localhost:2534/ticketdesk". TicketDesk will figure out the virtual directory part of the paths for you.
  • TicketDesk doesn't notify the user that submitted or changed the ticket. This is an anti-noise mechanism designed to reduce the number of notifications users receive. TicketDesk doesn't notify you about changes you made yourself, and this includes the "new ticket" notification.
  • The best way to test notifications is to setup two users accounts, one in helpdesk role, the other in ticketsubmitters. Create the ticket under one account, and then login as the other account and make changes. Check both email accounts to see notifications.
Sep 5, 2013 at 3:03 PM
Sep 8, 2013 at 5:46 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 8, 2013 at 5:59 AM
fixed in changeset b42431fb4d9c, on master