Click here to Skip to main content
15,889,868 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi People !
I have a question about accessing the path of virtual directory at IIS in which our site is hosted.
I created new site on IIS and then referenced published site into it as a virtual directory.
i.e. siteName = MySite & Virtual Directory = MySiteVD

now when i code
C#
Server.MapPath(".")

it returns to me the path till MySite whereas i need complete path upto MySiteVD

is there any way to get complete path (including virtual directory as well)?
Posted

1 solution

Server.MapPath(".") returns the current physical directory of the file (e.g. aspx) being executed
Server.MapPath("..") returns the parent directory
Server.MapPath("~") returns the physical path to the root of the application
Server.MapPath("/") returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)

Check out this link for more info:
http://stackoverflow.com/questions/275781/server-mappath-server-mappath-server-mappath-server-mappath[^]

...or do you need ResolveURL?
http://www.mycsharpcorner.com/Post.aspx?postID=45[^]

Good luck!
 
Share this answer
 
v2
Comments
Amir Mahfoozi 25-Oct-11 8:27am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900