Server.MapPath(“.”), Server.MapPath(“~”), Server.MapPath(@“\”), Server.MapPath(“/”). What is the difference?

后端 未结 3 468
谎友^
谎友^ 2020-11-21 23:59

Can anyone explain the difference between Server.MapPath(\".\"), Server.MapPath(\"~\"), Server.MapPath(@\"\\\") and Server.MapPa

3条回答
  •  星月不相逢
    2020-11-22 00:28

    1) Server.MapPath(".") -- Returns the "Current Physical Directory" of the file (e.g. aspx) being executed.

    Ex. Suppose D:\WebApplications\Collage\Departments

    2) Server.MapPath("..") -- Returns the "Parent Directory"

    Ex. D:\WebApplications\Collage

    3) Server.MapPath("~") -- Returns the "Physical Path to the Root of the Application"

    Ex. D:\WebApplications\Collage

    4) Server.MapPath("/") -- Returns the physical path to the root of the Domain Name

    Ex. C:\Inetpub\wwwroot

提交回复
热议问题