Multiple paths in ASP. NET

Source: Internet
Author: User

Multiple paths in ASP. NET

Request Information

Request. AppRelativeCurrentExecutionFilePath ~ /SysOption/BillingSetup1.aspx

Request. ApplicationPath/

Request. CurrentExecutionFilePath/SysOption/BillingSetup1.aspx

Request. FilePath/SysOption/BillingSetup1.aspx

Request. Path/SysOption/BillingSetup1.aspx

Request. PathInfo has no other usage to be tested)

Request. PhysicalApplicationPath D: \ VssWorkFolder \ briish_school_mis \ src \ WebSite \

Request. PhysicalPath D: \ VssWorkFolder \ briish_school_mis \ src \ WebSite \ SysOption \ BillingSetup1.aspx

Request. UserHostAddress 192.168.1.6

Request. UserHostName 192.168.1.6

Request. Url. ToString () http: // 192.168.1.6/SysOption/BillingSetup1.aspx? X = d

Request. UrlReferrer: Empty reference or jump to the Source Page address

Related information obtained from the Request. ServerVariables collection:

The left column is the server variable name, the right column is the value, and the value is obtained through Request. ServerVariables [server variable name ].

 
 
  1. APPL_MD_PATH : /LM/W3SVC/894523/Root  
  2. APPL_PHYSICAL_PATH : D:\VssWorkFolder\British_School_MIS\src\WebSite\  
  3. INSTANCE_META_PATH : /LM/W3SVC/894523  
  4. LOCAL_ADDR : 192.168.1.6  
  5. PATH_INFO : /SysOption/BillingSetup1.aspx  
  6. PATH_TRANSLATED : D:\VssWorkFolder\British_School_MIS\src\WebSite\SysOption\BillingSetup1.aspx  
  7. REMOTE_ADDR : 192.168.1.6  
  8. REMOTE_HOST : 192.168.1.6  
  9. SCRIPT_NAME : /SysOption/BillingSetup1.aspx  
  10. SERVER_NAME : 192.168.1.6  
  11. URL : /SysOption/BillingSetup1.aspx 

Request. ServerVariables is a powerful tool that can help us get a lot of client and web host information. If you are interested, you can use the following code to see what information it contains.

 
 
  1. foreach (string s in Request.ServerVariables)  
  2. {  
  3.     Response.Write(s + "  :  " + Request.ServerVariables[s] + "  
  4.  
  5.  

Path conversion in ASP. NET

1. convert to the Server path Server. MapPath)

An interesting question about web server development and design is address translation. For example, http address/images/a.txt. If you want to read the file through io on the server side, you must have the local address of the file "c: \ windows \ system32 \ xx. dll) ", then Server. mapPath is useful.

Response. Write (Request. MapPath (Request. Path); output: D: \ VssWorkFolder \ briish_school_mis \ src \ WebSite \ SysOption \ BillingSetup1.aspx

2. Convert to http address Page. ResolveClientUrl Page. ResolveUrl)

Response. Write (Page. ResolveClientUrl ("~ /A/a.jpg "). The output is ../a/a.jpg.

Response. Write (Page. ResolveUrl ("~ /A/a.jpg "). The output is/a/a.jpg.

Here is a detailed description of various paths in ASP. NET.

This article is from zyip's blog post "n paths in asp.net"

  1. Implementation of ASP. NET report printing: Paging Calculation Method
  2. ASP. NET DataGrid custom paging source code
  3. Implementation of ASP. NET paging code (C #, FCKeditor)
  4. Overview of ASP. NET basic syntax
  5. ASP. NET Installation Steps

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.