測試url : http://www.test.com:80/aaa/a.aspx?id=5&name=yh
【1】獲取 完整url (協議名+域名+站點名+文件名+參數)
string url=Request.Url.ToString();
【2】獲取 域名:
string url=HttpContext.Current.Request.Url.Host;
【3】獲取 端口:
int port = HttpContext.Current.Request.Url.Port;
【4】獲取 文件路徑+頁面名:
string url= HttpContext.Current.Request.Path;
【5】獲取 文件路徑+頁面名+參數:
string url=Request.RawUrl;
【6】獲取 參數(?號及其後面的參數):
string url= HttpContext.Current.Request.Url.Query;