How does ASP. NET obtain the URL address in the address bar?

Source: Internet
Author: User

How does ASP. NET obtain the URL address in the address bar? See the following implementation method:

First:

Http://www.liehuo.net/liehuonet/default.aspx

Request. applicationpath:/liehuonet
Request. currentexecutionfilepath:/liehuonet/default. aspx
Request. filepath:/liehuonet/default. aspx
Request. Path:/liehuonet/default. aspx
Request. rawurl:/liehuonet/default. aspx
Request. url. absolutepath:/liehuonet/default. aspx
Request. url. absoluteuri: http://www.liehuo.net/liehuonet/default.aspx
Request. url. HOST: www.liehuo.net
Request. url. localpath:/liehuonet/default. aspx

Second:

Rawurl
The original URL of the current request.
Remarks

The original URL is defined
The part after the domain information in the URL. In the URL string
Http://www.liehuo.net/cn/introduct/lanmu_24_57.html, original URL
It is/CN/introduct/lanmu_24_57.html. The original URL contains the query string (if any ).

The URL for the test is http://www.liehuo.net/liehuonet/default.aspx? Id = 1. The result is as follows:

Request. applicationpath:/liehuonet

Request. currentexecutionfilepath:/liehuonet/default. aspx

Request. filepath:/liehuonet/default. aspx

Request. Path:/liehuonet/default. aspx

Request. pathinfo:

Request. physicalapplicationpath: e: \ www \ liehuonet \

Request. physicalpath: e: \ www \ liehuonet \ default. aspx

Request. rawurl:/liehuonet/default. aspx? Id = 1

Request. url. absolutepath:/liehuonet/default. aspx

Request. url. absoluteuri: http://www.liehuo.net/liehuonet/default.aspx? Id = 1

Request. url. HOST: www.liehuo.net

Request. url. localpath:/liehuonet/default. aspx

Get URL:
1. obtained through ASP. NET
If the URL for the test is a http://www.test.com/testweb/default.aspx, the results are as follows:

Request. applicationpath:/testweb
Request. currentexecutionfilepath:/testweb/default. aspx
Request. filepath:/testweb/default. aspx
Request. Path:/testweb/default. aspx
Request. physicalapplicationpath: e: \ www \ testweb \
Request. physicalpath: e: \ www \ testweb \ default. aspx
Request. rawurl:/testweb/default. aspx
Request. url. absolutepath:/testweb/default. aspx
Request. url. absoluteurl: http://www.test.com/testweb/default.aspx
Request. url. HOST: www.test.com
Request. url. localpath:/testweb/default. aspx

2. Get it through JS

<Table width = 100% cellpadding = 0 cellspacing = 0 border = 0>
<SCRIPT>
Thisurl = Document. url;
Thishref = Document. Location. href;
Thissloc = self. Location. href;
Thisdloc = Document. location;

Strwrite = "<tr> <TD valign = top> thisurl:
</TD> <TD> ["+ thisurl +
"] </TD> </tr>" strwrite + = "<tr> <TD
Valign = top> thishref: </TD> <TD> ["+ thishref +
"] </TD> </tr>" strwrite + = "<tr> <TD
Valign = top> thissloc: </TD> <TD> ["+ thissloc +
"] </TD> </tr>" strwrite + = "<tr> <TD
Valign = top> thisdloc: </TD> <TD> ["+ thisdloc +
"] </TD> </tr>" document. Write (strwrite );
</SCRIPT>
Thisdloc = Document. Location; <br>
Thisurl = Document. url; <br>
Thishref = Document. Location. href; <br>
Thissloc = self. Location. href; <br>
<SCRIPT>
Thistloc = top. Location. href;
Thisploc = parent.doc ument. location;
Thisthost = top. Location. hostname;
Thishost = location. hostname;

Strwrite = "<tr> <TD valign = top> thistloc:
</TD> <TD> ["+ thistloc +
"] </TD> </tr>" strwrite + = "<tr> <TD
Valign = top> thisploc: </TD> <TD> ["+ thisploc +
"] </TD> </tr>" strwrite + = "<tr> <TD
Valign = top> thisthost: </TD> <TD> ["+ thisthost +
"] </TD> </tr>" strwrite + = "<tr> <TD
Valign = top> thishost: </TD> <TD> ["+ thishost +
"] </TD> </tr>" document. Write (strwrite );
</SCRIPT>
Thistloc = top. Location. href; <br>
Thisploc = parent.doc ument. Location; <br>
Thisthost = top. Location. hostname; <br>
Thishost = location. hostname; <br>
<SCRIPT>
Tmphpage = thishref. Split ("/");
Thishpage = tmphpage [tmphpage. Length-1];
Tmpupage = thisurl. Split ("/");
Thisupage = tmpupage [tmpupage. Length-1];

Strwrite = "<tr> <TD valign = top> thishpage:
</TD> <TD> ["+ thishpage +
"] </TD> </tr>"
Strwrite + =
"<Tr> <TD valign = top> thisupage: </TD> <TD> ["
+ Thisupage + "] </TD> </tr>"
Document. Write (strwrite );
</SCRIPT> <tr> <TD>

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.