Server.MapPath in ASP.NET, ASPX, MVC, MVC 3 and NET Framework.

Server.MapPath specifies the relative or virtual path to map to a physical directory.

1. Server.MapPath(“.”) returns the current physical directory of the file (e.g. aspx) being executed

2. Server.MapPath(“..”) returns the parent directory

3. Server.MapPath(“~”) returns the physical path to the root of the application

4. Server.MapPath(“/”) returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)

An example:

Let’s say you pointed a web site application ( to

and installed your shop application (sub web as virtual directory in IIS, marked as application) in


For example, if you call Server.MapPath in following request:

1. Server.MapPath(“.”) returns D:WebAppsshopproducts

2. Server.MapPath(“..”) returns D:WebAppsshop

3. Server.MapPath(“~”) returns D:WebAppsshop

4. Server.MapPath(“/”) returns C:Inetpubwwwroot

5. Server.MapPath(“/shop”) returns D:WebAppsshop

Source Author