Request获取URL的各种信息
类别:编程学习 浏览量:790
时间:2017-1-10 Request获取URL的各种信息
Request获取URL的各种信息以 http://localhost:51566/test/Default.aspx?id=56 为例
//获取完整url (协议名+域名+站点名+文件名+参数)
string fullUrl = Request.Url.ToString();
//获取客户端请求的URL信息(不包括主机和端口)
string rawUrl = Request.RawUrl;
//获取站点名+页面名
string absolutePath = Request.Url.AbsolutePath;
//获取主机部分
string urlHost = Request.Url.Host;
//获取参数部分
string urlQuery = Request.Url.Query;
//获取服务器上ASP.NET应用程序的虚拟路径
string ApplicationPath = Request.ApplicationPath;
//获取当前请求的虚拟路径
string CurrentExecutionFilePath = Request.CurrentExecutionFilePath;
//获取当前请求的虚拟路径
string Path = Request.Path;
//获取具有URL扩展名的资源的附加路径信息
string PathInfo = Request.PathInfo;
//获取与请求的URL相对应的物理文件系统路径
string PhysicalPath = Request.PhysicalPath;
//获取文件名的本地操作系统表示形式
string LocalPath = Request.Url.LocalPath;
//获取绝对URL
string AbsoluteUri = Request.Url.AbsoluteUri;
StringBuilder sb = new StringBuilder();
sb.Append("Request.Url.ToString(): " + fullUrl + "<br />");
sb.Append("Request.RawUrl: " + rawUrl + "<br />");
sb.Append("Request.Url.AbsolutePath: " + absolutePath + "<br />");
sb.Append("Request.Url.Host: " + urlHost + "<br />");
sb.Append("Request.Url.Query: " + urlQuery + "<br />");
sb.Append("Request.ApplicationPath: " + ApplicationPath + "<br />");
sb.Append("Request.CurrentExecutionFilePath: " + CurrentExecutionFilePath + "<br />");
sb.Append("Request.Path: " + Path + "<br />");
sb.Append("Request.PathInfo: " + PathInfo + "<br />");
sb.Append("Request.PhysicalPath: " + PhysicalPath + "<br />");
sb.Append("Request.Url.LocalPath: " + LocalPath + "<br />");
sb.Append("Request.Url.AbsoluteUri: " + AbsoluteUri + "<br />");
Response.Write(sb.ToString());
输出结果
Request.Url.ToString(): http://localhost:51566/test/Default.aspx?id=56
Request.RawUrl: /test/Default.aspx?id=56
Request.Url.AbsolutePath: /test/Default.aspx
Request.Url.Host: localhost
Request.Url.Query: ?id=56
Request.ApplicationPath: /
Request.CurrentExecutionFilePath: /test/Default.aspx
Request.Path: /test/Default.aspx
Request.PathInfo:
Request.PhysicalPath: D:\example\WebSite1\test\Default.aspx
Request.Url.LocalPath: /test/Default.aspx
Request.Url.AbsoluteUri: http://localhost:51566/test/Default.aspx?id=56
标签:Request
您可能感兴趣
- pythonrequests爬虫使用教程(Python 通过requests实现腾讯新闻抓取爬虫的方法)
- requests使用自定义cookie(Yii框架中用response保存cookie,用request读取cookie的原理解析)
- 从客户端检测到有潜在危险的Request.Form值
- laravel接口请求模拟(Laravel框架控制器的request与response用法示例)
- Request获取URL的各种信息
- python如何安装requests模块(Python常用模块之requests模块用法分析)
- tomcat运行警告(tomcat异常解决Invalid character found in the request target. The valid characters are defined in)
- python爬虫入门代码(python爬虫基础教程:requests库二代码实例)
- pythonrequests框架实例(Python requests模块实例用法)
- Request.Url的值有可能会带端口号
- Request、Request.Form、Request.QueryString的区别
- laravel零基础(基于laravel Request的所有方法详解)
- dedecms参数不显示(织梦DedeCms中出现Safe Alert: Request Error step 1/2 的解决方法)
- python爬取豆瓣电影评论(python使用requests模块实现爬取电影天堂最新电影信息)
- thinkphp5怎么设置当前的模块(thinkPHP5.1框架中Request类四种调用方式示例)
- HttpWebRequest的使用
- 《红 雄安》系列广播剧第一集 水上奇兵雁翎队(雄安系列广播剧第一集)
- 小说 小伙穿越成刘备,用现代知识指挥作战,众谋士都看呆了(小伙穿越成刘备)
- 解析葡萄牙6-1瑞士 进攻多点开花,贡萨洛-拉莫斯一战成名(解析葡萄牙6-1瑞士)
- 这支 奇兵队 腕大 有范儿还各怀绝技,毒贩杀人犯见了都要仓皇而逃(这支奇兵队腕大)
- 雄藩崛起 奇兵队与幕末长州藩军事改革(雄藩崛起奇兵队与幕末长州藩军事改革)
- 九月初,爱如蜜糖,甜到心扉,迷恋彼此,一日不见兮,思之若狂(九月初爱如蜜糖)
热门推荐
- php 日志监控(php日志函数error_log用法实例分析)
- 移动端web页面使用position:fixed
- mysql全表查询如何优化(MySQL 分组查询的优化方法)
- docker安装详细教程linux(linux中docker的安装教程)
- docker部署高性能服务器(Docker部署SQL Server 2019 Always On集群的实现)
- mysql索引应该注意的地方(关于MySQL索引知识的小妙招)
- springboot项目部署到docker(IDEA 通过docker插件发布springboot项目的详细教程)
- 织梦cms中的模块怎么设置(织梦CMS模板在runphp=yes的标签中调用其他field值的方法)
- JavaScript实现网页版贪吃蛇游戏(JavaScript实现网页版贪吃蛇游戏)
- docker挂载的注意事项(解决docker日志挂载的问题)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9