Last post Sep 12, 2008 08:48 AM by shalan99
Aug 10, 2008 08:17 PM|vmirage|LINK
Is there a way to get the virtualpath base on the subdomain? For example I have
app1.mydomain.com which is pointed to www.mydomain.com/app1
when I call VirtualPathUtility when running the application from app1.mydomain.com, I would like to return '~' as '/', instead of '/app1'.
Aug 14, 2008 05:03 AM|Thomas Sun – MSFT|LINK
We can use VirtualPathUtility's ToAppRelative method to convert a virtual path to an application-relative path.
StringBuilder sb2 = new StringBuilder();
String pathstring1 = Context.Request.CurrentExecutionFilePath.ToString();
sb2.Append("Current Executing File Path = " + pathstring1.ToString() +
sb2.Append("Is Absolute = " + VirtualPathUtility.IsAbsolute(pathstring1).ToString() +
sb2.Append("Is AppRelative = " + VirtualPathUtility.IsAppRelative(pathstring1).ToString() +
sb2.Append("Make AppRelative = " +
For more information, see
I look forward to hearing from you.
Aug 14, 2008 09:14 PM|vmirage|LINK
I don't think this is a full proof solution.
For instance, if I would to browse through app1.domain.com/, or browse through www.domain.com/app1/, ToAppRelative will return identical results.
If for instance i would like to write an inline code to <img src="<%=path.Replace("~","")%>\filename.jpg">,
Browsing to www.domain.com/app1 would fail to return the image, but app1.domain.com would work nicely. My idea is to have '/app1' return when browsing to www.domain.com/app1, but return as '/' when browsing to app1.domain.com
For a slightly more real life example...
file is located at
or equilly as
so, browsing to www.domain.com/app1/default.aspx, i would like to get '~/images/logo.jpg' as '/app1/images/logo.jpg',
but browsing to app1.domain.com/default.aspx, would return '~/images/logo.jpg' as '/images/logo.jpg'.
I am actually giving this example because I am writing program using localhost, but would later publish it to a hosting with subdomain and do not intend to modify the code just to suit the published website.
Sep 12, 2008 08:48 AM|shalan99|LINK
did you manage to sort out this issue?
I have a similar problem - I am developing a custom file browser for FCKeditor in my asp.net 2.0 app. The content management is done under a subdomain app for administration. The file setup is as follows:
- folder 1
- folder 2
- folder 3
The admin folder was automatically created when I created the subdomain (http://admin.sometestingwebsite.com) and "hosts" the separate cms application.
All images are stored under wwwroot/folder3/images
how would I read the images from the in the admin subdomain?