Introduction and Demonstration
Many times we need to know the full path of remote server where we are hosting
or the exact location of file but if we don't how we can't. Actually we have
MapPath method which maps the specified relative or virtual path to the
corresponding physical directory on the web server. Usually any web server never
allows to access in any path if we don't have proper permission. Even we can't
list the directories or file as we list in DOS like
![server1.gif]()
As in above picture, we can list on web server via remotely without proper
permission because of security reason. But we can see the full path where the
particular page exists as in example given below.
![server2.gif]()
In above example, coded (given below) file is being hosted at remote server and
it is displaying (mapping) the physical location (path) of my hosting server.
Here is my coding I have used.
protected
void Page_Load(object
sender, EventArgs e)
{
Response.Write(Server.MapPath("."));
Response.Write("<br>");
Response.Write(Server.MapPath(""));
Response.Write("<br>");
Response.Write(Server.MapPath("~"));
}
HAVE A HAPPY CODING!