Obtain URL parameters
Suppose the full address of the current page is: http://www.test.com/aaa/bbb.aspx? Id = 5 & name = kelli
"Http: //" is the protocol name.
"Www.test.com" is a domain name
"AAA" is the site name
"BBB. aspx" is the page name (file name)
"Id = 5 & name = Kelli" is a parameter
[1] obtain the complete URL (protocol name + domain name + site name + file name + parameter)
String url = request. url. tostring ();
Url = http://www.test.com/aaa/bbb.aspx? Id = 5 & name = kelli
[2] retrieve site name + Page name + parameters:
String url = request. rawurl;
(Or string url = request. url. pathandquery ;)
Url =/AAA/BBB. aspx? Id = 5 & name = kelli
[3] retrieve site name + Page name:
String url = httpcontext. Current. Request. url. absolutepath;
(Or string url = httpcontext. Current. Request. Path ;)
Url = aaa/BBB. aspx
[4] retrieve domain names:
String url = httpcontext. Current. Request. url. Host;
Url = www.test.com
[5] GET parameters:
String url = httpcontext. Current. Request. url. query;
Url =? Id = 5 & name = kelli
From: http://www.cnblogs.com/rhythmK/archive/2010/03/08/1680562.html