Meaning of each attribute of Request. Url in Asp.net, asp. netrequest. url

Source: Internet
Author: User

Meaning of each attribute of Request. Url in Asp.net, asp. netrequest. url
Meanings of each attribute of Request. Url in Asp.net

This article Reprinted from http://www.jb51.net/article/30254.htm

 

The description of Request. Url on the network is already rich, but I have practiced it to check whether the final result is consistent with that on the network. 1. Simple environment setup
On the local IIS, a website is configured with the host Name wjnhome.com, port 88, and a virtual directory pointing to the same site. The virtual directory name is virtual, and the host configuration is 127.0.0.1 wjnhome.com.
So the address is: http://jb51.net: 88/virtual/urldemo. aspx? Id = 2 # top
2. Write simple code 
// Virtual directory path
Response. Write ("<strong> Request. ApplicationPath: </strong>" + Request. ApplicationPath + "</br> ");
// The physical path of the site (full path)
Response. Write ("<strong> Request. PhysicalPath: </strong>" + Request. PhysicalPath + "</br> ");
// Directory of the physical path of the site
Response. Write ("<strong> DirectoryName: </strong>" + System. IO. Path. GetDirectoryName (Request. PhysicalPath) + "</br> ");
// Directory of the physical path of the site
Response. Write ("<strong> Request. PhysicalApplicationPath: </strong>" + Request. PhysicalApplicationPath + "</br> ");
// File Name of the current page
Response. Write ("<strong> FileName: </strong>" + System. IO. Path. GetFileName (Request. PhysicalPath) + "</br> ");
// The Virtual Path of the current page
Response. Write ("<strong> Request. CurrentExecutionFilePath: </strong>" + Request. CurrentExecutionFilePath + "</br> ");
// The Virtual Path of the current page
Response. Write ("<strong> Request. FilePath: </strong>" + Request. FilePath + "</br> ");
Response. Write ("<strong> Request. Path: </strong>" + Request. Path + "</br> ");
// Original URL
Response. Write ("<strong> Request. RawUrl: </strong>" + Request. RawUrl + "</br> ");
// Absolute path (excluding parameters or something)
Response. Write ("<strong> Request. Url. AbsolutePath: </strong>" + Request. Url. AbsolutePath + "</br> ");
// Absolute URL
Response. Write ("<strong> Request. Url. AbsoluteUri: </strong>" + Request. Url. AbsoluteUri + "</br> ");
// URL protocol Scheme
Response. Write ("<strong> Request. Url. Scheme: </strong>" + Request. Url. Scheme + "</br> ");
// Host name of the URL
Response. Write ("<strong> Request. Url. Host: </strong>" + Request. Url. Host + "</br> ");
// URL port number
Response. Write ("<strong> Request. Url. Port: </strong>" + Request. Url. Port + "</br> ");
// Host name + port number
Response. Write ("<strong> Request. Url. Authority: </strong>" + Request. Url. Authority + "</br> ");
// Obtain the local operating system representation of the file name
Response. Write ("<strong> Request. Url. LocalPath: </strong>" + Request. Url. LocalPath + "</br> ");
// Additional path information such as http://jb51.net: 88/UrlDemo. aspx/Hello? Id = 22 # top so here is Hello
Response. Write ("<strong> Request. PathInfo: </strong>" + Request. PathInfo + "</br> ");
// URL path and GET Parameter
Response. Write ("<strong> Request. Url. PathAndQuery: </strong>" + Request. Url. PathAndQuery + "</br> ");
// GET parameters of the URL
Response. Write ("<strong> Request. Url. Query: </strong>" + Request. Url. Query + "</br> ");
// Mainly refers to the http://jb51.net: 88/UrlDemo. aspx/Hello? Id = 22 # top in # top next.
// However, the value cannot be obtained normally because the browser does not send the value to the server.
Response. Write ("<strong> Request. Url. Fragment: </strong>" + Request. Url. Fragment + "</br> ");
// Host name
Response. Write ("<strong> Request. Url. DnsSafeHost: </strong>" + Request. Url. DnsSafeHost + "</br> ");
// All URLs
Response. Write ("<strong> Request. Url. OriginalString: </strong>" + Request. Url. OriginalString + "</br> ");
// In this case Uri uriAddress = new Uri ("http: // user: password@www.contoso.com/index.htm") Console. WriteLine (uriAddress. UserInfo );
Response. Write ("<strong> Request. Url. UserInfo: </strong>" + Request. Url. UserInfo + "</br> ");
// The value of the Source Page is displayed when you jump from a page.
Response. Write ("<strong> Request. UrlReferrer: </strong>" + Request. UrlReferrer + "</br> ");
// Each segment of the URI
For (var I = 0; I <Request. Url. Segments. Length; I ++)
{
Response. write ("<strong> Request. url. segment "+ I +": </strong> "+ Request. url. segments [I] + "</br> ");
}
3. output results
Request. ApplicationPath:/virtual
Request. PhysicalPath: E: \ VsProject \ 201200420 \ UrlDemo \ urldemo. aspx
DirectoryName: E: \ VsProject \ 201200420 \ UrlDemo
Request. PhysicalApplicationPath: E: \ VsProject \ 201200420 \ UrlDemo \
FileName: urldemo. aspx
Request. CurrentExecutionFilePath:/virtual/urldemo. aspx
Request. FilePath:/virtual/urldemo. aspx
Request. Path:/virtual/urldemo. aspx
Request. RawUrl:/virtual/urldemo. aspx? Id = 2
Request. Url. AbsolutePath:/virtual/urldemo. aspx
Request. Url. AbsoluteUri: http://jb51.net: 88/virtual/urldemo. aspx? Id = 2
Request. Url. Scheme: http
Request. Url. Host: wjnhome.com
Request. Url. Port: 88
Request. Url. Authority: wjnhome.com: 88
Request. Url. LocalPath:/virtual/urldemo. aspx
Request. PathInfo:
Request. Url. PathAndQuery:/virtual/urldemo. aspx? Id = 2
Request. Url. Query :? Id = 2
Request. Url. Fragment:
Request. Url. DnsSafeHost: wjnhome.com
Request. Url. OriginalString: http://jb51.net: 88/virtual/urldemo. aspx? Id = 2
Request. Url. UserInfo:
Request. UrlReferrer:
Request. Url. Segment0 :/
Request. Url. Segment1: virtual/
Request. Url. Segment2: urldemo. aspx

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.