Open In App

ASP Server.MapPath Method

The MapPath method is used to define a relative virtual path for a physical directory on the server.       

Note: This method cannot be used in Session.OnEnd and Application.OnEnd.

Syntax:

Server.MapPath(path)                                                               

  Parameter Value:

Example Code: Below code that demonstrates the use of the Server.MapPath Method.

<%
response.write(Server.MapPath("test.asp") & "<br>")
response.write(Server.MapPath("script/test.asp") & "<br>")
response.write(Server.MapPath("/script/test.asp") & "<br>")
response.write(Server.MapPath("\script") & "<br>")
response.write(Server.MapPath("/") & "<br>")
response.write(Server.MapPath("\") & "<br>")
%>

Output  

c:\inetpub\wwwroot\script\test.asp
c:\inetpub\wwwroot\script\script\test.asp
c:\inetpub\wwwroot\script\test.asp
c:\inetpub\wwwroot\script
c:\inetpub\wwwroot
c:\inetpub\wwwroot
Article Tags :