string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost/learnmore.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
// /localhost/learnmore.aspx
string host = HttpContext.Current.Request.Url.Host;
// localhost
編集: クエリ文字列項目を削除するには: ( Get url without querystringから見つかりました)
var uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
string path = uri.GetLeftPart(UriPartial.Path);
また
Uri url = new Uri("http://www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye");
string path = String.Format("{0}{1}{2}{3}", url.Scheme,
Uri.SchemeDelimiter, url.Authority, url.AbsolutePath);
また
string url = "http://www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye";
string path = url.Substring(0, url.IndexOf("?"));