URL 的各个部分和通过ASP.NET获取URL地址的方法

来源:互联网 发布:哪个旅行软件好用 编辑:程序博客网 时间:2024/05/20 17:59
網址:http://localhost:1897/News/Press/Content.aspx/123?id=1#tocRequest.ApplicationPath/Request.PhysicalPathD:/Projects/Solution/web/News/Press/Content.aspxSystem.IO.Path.GetDirectoryName(Request.PhysicalPath)D:/Projects/Solution/web/News/PressRequest.PhysicalApplicationPathD:/Projects/Solution/web/System.IO.Path.GetFileName(Request.PhysicalPath)Content.aspxRequest.CurrentExecutionFilePath/News/Press/Content.aspxRequest.FilePath/News/Press/Content.aspxRequest.Path/News/Press/Content.aspx/123Request.RawUrl/News/Press/Content.aspx/123?id=1Request.Url.AbsolutePath/News/Press/Content.aspx/123Request.Url.AbsoluteUrihttp://localhost:1897/News/Press/Content.aspx/123?id=1Request.Url.SchemehttpRequest.Url.HostlocalhostRequest.Url.Port1897Request.Url.Authoritylocalhost:1897Request.Url.LocalPath/News/Press/Content.aspx/123Request.PathInfo/123Request.Url.PathAndQuery/News/Press/Content.aspx/123?id=1Request.Url.Query?id=1Request.Url.Fragment
Request.Url.Segments/
News/
Press/
Content.aspx/
123

 

 

 

 

 

 

 

 

 

如果测试的url地址是http : //www.test.com/testweb/default.aspx, 结果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PhysicalApplicationPath: E:/WWW/testwebRequest.PhysicalPath:
Request.PhysicalPath: E:/WWW/testweb/default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUrl: [url]http://www.test.com/testweb/default.aspx[/url]
Request.Url.Host: [url]www.test.com[/url]
Request.Url.LocalPath: /testweb/default.aspx

原创粉丝点击