Comparison of various methods for obtaining url information

  • 2020-05-07 19:33:17
  • OfStack

Address of this page: Request.URL;
Address on previous page:
 
Request.UrlReferrer 
Request.ServerViables["http_referer"] 
Request.RawUrl 
Request.RawUrl.QueryAndPath 
System.IO.Path.GetFileName(Request.FilePath.ToString()) 

In ASP.NET programming, Request is often needed to obtain information about url, Request has a variety of methods to obtain url information, but I often forget the specific function of various methods, today I wrote a test program, the results of various methods are listed, and then directly refer to 1.
Test url address is 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.PathInfo: 
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.AbsoluteUri: http://www.test.com/testweb/default.aspx 
Request.Url.Host: www.test.com 
Request.Url.LocalPath: /testweb/default.aspx 

When taking parameters in url, the following can be used:
HttpContext.Current.Request.Url.PathAndQuery.ToString()

Related articles: