HttpContext.Current.Request.Url

Source: Internet
Author: User

Assuming the current page full address is: Http://www.test.com/aaa/bbb.aspx?id=5&name=kelli
protocol name ----/http
domain name ----www.test.com
Site name ---AAA
page name (file name) ----bbb.aspx
parameter ------Id=5&name=kelli


1. Full URL (protocol name + domain + site name + filename + parameter)
String url=request.url.tostring ();
Url= Http://www.test.com/aaa/bbb.aspx?id=5&name=kelli

2. Site name + page name + parameters
string Url=request.rawurl; (or string url=request.url.pathandquery;)
Url=/aaa/bbb.aspx?id=5&name=kelli

3. Site name + page name
String Url=httpcontext.current.request.url.absolutepath;
(or string url= HttpContext.Current.Request.Path;)
Url= aaa/bbb.aspx

4. Domain Name
String Url=httpcontext.current.request.url.host;
Url= www.test.com

5. Parameters
String Url= HttpContext.Current.Request.Url.Query;
Url=? Id=5&name=kelli

HttpContext.Current.Request.Url

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.