1

Resolved

Configuration in Virtual Directory

description

When hosting the web application in a virtual directory, the path resolution used to resolve configuration file values fails.

[WebsiteRoot][MyTrip_VirtualDirectory]

Server.MapPath("App_Data") will resolve to [WebsiteRoot]/App_Data, not [WebsiteRoot]/[MyTrip_VirtualDirectory]\App_Data where the desired configuration file actually resides.

P.S. - This is Bug 1 of 5 (to join the project) =D

file attachments

comments

XamlZealot wrote Oct 17, 2012 at 1:57 PM

Should anyone find this useful:

I resolved the Virtual Directory issue by creating the following static method in mtm.Core\Settings\GeneralMethods.cs:

public static string GetHostingPath()
{
return HttpContext.Current.Server.MapPath("~");
}

Then changing all 82 references of HttpContext.Current.Server.MapPath() to call this method and using System.IO.Path.Combine() to create paths to the necessary files:

string absolutDirectory = Path.Combine(GetHostingPath(), "Web.config");

NOTE: Using the ~ will always resolve to the APPLICATION root, not the DOMAIN root...so as long as your virtual directory is configured as an application in IIS, this will resolve to the absolute location of your MyTrip application files.

wrote Oct 17, 2012 at 2:07 PM

wrote Oct 18, 2012 at 7:57 PM

Resolved with changeset 95405.

wrote Oct 18, 2012 at 7:59 PM

wrote Feb 14, 2013 at 2:42 AM

wrote May 16, 2013 at 8:20 AM

wrote May 16, 2013 at 8:20 AM

wrote Jun 14, 2013 at 7:57 AM