Asp. NET gets the various properties of the current URL (protocol name, domain name, site, page, etc.)

Source: Internet
Author: User

Set current page full address is: http://www.cnblogs.com/trvatwang/p/4463026.html?id=xxx
"/HTTP" is the protocol name
"Www.cnblogs.com" is the domain name
"Trvatwang" is the station name.
"4463026.html" is the page name (file name)
"Id=xxx" is a parameter

1. Get the full URL (protocol name + domain + site name + file name + parameters)

string url=Request.Url.ToString (); URL= http://www.cnblogs.com/trvatwang/p/ 4463026.html?id=xxx

2. Get Site name + page name + parameters

string url=string// can also be used in this way url=/trvatwang/p/4463026

3. Get Site name + page name

string url=string url= HttpContext.Current.Request.Path; //  url=/trvatwang/p/4463026. html

4. Get the domain name

string url=HttpContext.Current.Request.Url.Host; URL= www.cnblogs.com

5. Get Parameters

string url= HttpContext.Current.Request.Url.Query; URL=? id=xxx
Request.rawurl: Gets the URL information for the client request (not including the host and port)------>/default2.aspx Request.applicationpath: Gets the virtual path of an ASP. NET application on the server. ------>/ Request.currentexecutionfilepath: Gets the virtual path of the current request. ------>/default2.aspx request.path: Gets the virtual path of the current request. ------>/default2.aspx request.pathinfo: Take additional path information for a resource with a URL extension ------>  Request.PhysicalPath: Gets the physical file system path that corresponds to the requested URL. ------>E:\temp\Default2.aspx Request.Url.LocalPath:------>/default2.aspx Request.Url.AbsoluteUri:------>http://

Asp. NET gets the various properties of the current URL (protocol name, domain name, site, page, etc.)

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.