zoukankan      html  css  js  c++  java
  • Server.MapPath

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

    • 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)

    An example:

    Let's say you pointed a web site application (http://www.example.com/) to

    C:\Inetpub\wwwroot

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

    D:\WebApps\shop

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

    http://www.example.com/shop/products/GetProduct.aspx?id=2342

    then:

    • Server.MapPath(".") returns D:\WebApps\shop\products
    • Server.MapPath("..") returns D:\WebApps\shop
    • Server.MapPath("~") returns D:\WebApps\shop
    • Server.MapPath("/") returns C:\Inetpub\wwwroot
    • Server.MapPath("/shop") returns D:\WebApps\shop

    If Path starts with either a forward (/) or backward slash (\), the MapPath method returns a path as if Path were a full, virtual path.

    If Path doesn't start with a slash, the MapPath method returns a path relative to the directory of the request being processed.

    Note: in C#, @ is the verbatim literal string operator meaning that the string should be used "as is" and not be processed for escape sequences.

  • 相关阅读:
    Android tcpdump 抓包
    Android CursorAdapter 查询联系人过滤
    Android 项目打包成apk文件
    解决Centos 6.3 中 gedit中文乱码问题
    在Linux(centos)系统上用手机调试android程序(eclipse)
    系统定时关机命令–shutdown
    使用gdb Server调试嵌入式程序
    Vim 错误排查方法
    通过netstat命令查看进程与端口的对应关系
    dexpler的使用方法
  • 原文地址:https://www.cnblogs.com/tracy/p/2094403.html
Copyright © 2011-2022 走看看