Asp.net中Request.Url的各个属性对应的意义介绍
Asp.net中Request.Url的各个属性对应的意义介绍
在本地IIS上配置了一个网站:主机名为wjnhome.com,端口88,然后建了一个虚拟目录指向同一站点,虚拟目录名称为virtual,配置host为127.0.0.1 wjnhome.com
所以地址就为:http://jb51.net:88/virtual/urldemo.aspx?id=2#top
2.编写简单的代码
//虚拟目录的路径
Response.Write("<strong>Request.ApplicationPath:</strong>" + Request.ApplicationPath + "</br>");
//站点的物理路径(完整路径)
Response.Write("<strong>Request.PhysicalPath:</strong>" + Request.PhysicalPath + "</br>");
//站点物理路径的目录
Response.Write("<strong>DirectoryName:</strong>" + System.IO.Path.GetDirectoryName(Request.PhysicalPath) + "</br>");
//站点物理路径的目录
Response.Write("<strong>Request.PhysicalApplicationPath:</strong>" + Request.PhysicalApplicationPath + "</br>");
//当前页面的文件名
Response.Write("<strong>FileName:</strong>" + System.IO.Path.GetFileName(Request.PhysicalPath) + "</br>");
//当前页面的虚拟路径
Response.Write("<strong>Request.CurrentExecutionFilePath:</strong>" + Request.CurrentExecutionFilePath + "</br>");
//当前页面的虚拟路径
Response.Write("<strong>Request.FilePath:</strong>" + Request.FilePath + "</br>");
Response.Write("<strong>Request.Path:</strong>" + Request.Path + "</br>");
//原始URL
Response.Write("<strong>Request.RawUrl:</strong>" + Request.RawUrl + "</br>");
//绝对路径(不包括参数什么的)
Response.Write("<strong>Request.Url.AbsolutePath:</strong>" + Request.Url.AbsolutePath + "</br>");
//绝对URL
Response.Write("<strong>Request.Url.AbsoluteUri:</strong>" + Request.Url.AbsoluteUri + "</br>");
//URL协议方案
Response.Write("<strong>Request.Url.Scheme:</strong>" + Request.Url.Scheme + "</br>");
//URL的主机名
Response.Write("<strong>Request.Url.Host:</strong>" + Request.Url.Host + "</br>");
//URL端口号
Response.Write("<strong>Request.Url.Port:</strong>" + Request.Url.Port + "</br>");
//主机名+端口号
Response.Write("<strong>Request.Url.Authority:</strong>" + Request.Url.Authority + "</br>");
//获取文件名的本地操作系统表现形式
Response.Write("<strong>Request.Url.LocalPath:</strong>" + Request.Url.LocalPath + "</br>");
//附加路径信息,例如http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top 那么这里就是Hello
Response.Write("<strong>Request.PathInfo:</strong>" + Request.PathInfo + "</br>");
//URL的路径和GET参数
Response.Write("<strong>Request.Url.PathAndQuery:</strong>" + Request.Url.PathAndQuery + "</br>");
//URL的GET参数
Response.Write("<strong>Request.Url.Query:</strong>" + Request.Url.Query + "</br>");
//主要指的是http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top中#后面的top。
//但一般情况下无法获取值,因为浏览器不会把这个值发送到服务器端
Response.Write("<strong>Request.Url.Fragment:</strong>" + Request.Url.Fragment + "</br>");
//主机名
Response.Write("<strong>Request.Url.DnsSafeHost:</strong>" + Request.Url.DnsSafeHost + "</br>");
//URL的全部
Response.Write("<strong>Request.Url.OriginalString:</strong>" + Request.Url.OriginalString + "</br>");
//这种情况 Uri uriAddress = new Uri ("http://user:password@www.contoso.com/index.htm ") Console.WriteLine(uriAddress.UserInfo);
Response.Write("<strong>Request.Url.UserInfo:</strong>" + Request.Url.UserInfo + "</br>");
//从某个页面跳转过来的时候会显示源页面的值
Response.Write("<strong>Request.UrlReferrer:</strong>" + Request.UrlReferrer + "</br>");
//URI的每一段
for (var i = 0; i < Request.Url.Segments.Length;i++ )
{
Response.Write("<strong>Request.Url.Segment" + i + ":</strong>" + Request.Url.Segments[i] + "</br>");
}
3.输出结果
Request.ApplicationPath:/virtual
Request.PhysicalPath:E:\VsProject\201200420\UrlDemo\UrlDemo\urldemo.aspx
DirectoryName:E:\VsProject\201200420\UrlDemo\UrlDemo
Request.PhysicalApplicationPath:E:\VsProject\201200420\UrlDemo\UrlDemo\
FileName:urldemo.aspx
Request.CurrentExecutionFilePath:/virtual/urldemo.aspx
Request.FilePath:/virtual/urldemo.aspx
Request.Path:/virtual/urldemo.aspx
Request.RawUrl:/virtual/urldemo.aspx?id=2
Request.Url.AbsolutePath:/virtual/urldemo.aspx
Request.Url.AbsoluteUri:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.Scheme:http
Request.Url.Host:wjnhome.com
Request.Url.Port:88
Request.Url.Authority:wjnhome.com:88
Request.Url.LocalPath:/virtual/urldemo.aspx
Request.PathInfo:
Request.Url.PathAndQuery:/virtual/urldemo.aspx?id=2
Request.Url.Query:?id=2
Request.Url.Fragment:
Request.Url.DnsSafeHost:wjnhome.com
Request.Url.OriginalString:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.UserInfo:
Request.UrlReferrer:
Request.Url.Segment0:/
Request.Url.Segment1:virtual/
Request.Url.Segment2:urldemo.aspx
Asp.net中Request.Url的各个属性对应的意义介绍的更多相关文章
- 转载MSDN 在ASP.NET 中执行 URL 重写
转载文章原网址 http://msdn.microsoft.com/zh-cn/library/ms972974.aspx 摘要:介绍如何使用 Microsoft ASP.NET 执行动态 URL 重 ...
- asp.net中Request.ServerVariables的用法
在asp.net中可以通过HttpRequest.ServerVariables 属性来获取“ Web 服务器变量的集合” HttpRequest.ServerVariables 的用法: HttpR ...
- ASP.NET中Request.RawUrl、Request.Url的区别
如果访问的地址是: http://hovertree.com/guestbook/addmessage.aspx?key=hovertree%3C&n=myslider#zonemenu 那么 ...
- ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath、Server.MapPath(转载)
1.Request.ApplicationPath->当前应用的目录 Jsp中, ApplicationPath指的是当前的application(应用程序)的目录,ASP.NET中也是这个 ...
- ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath、
1.Request.ApplicationPath->当前应用的目录 Jsp中, ApplicationPath指的是当前的application(应用程序)的目录,ASP.NET中也是这 ...
- ASP.NET 中Request.QueryString 中的key
在ASP.net中 的Key是可能为null的,例如在如下的Url中 http://localhost:14546/Home/Index?a 有一个key=null 其value是a,以前一直以为ke ...
- ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath
1.Request.ApplicationPath->当前应用的目录 2.Request.FilePath->对应于iis的虚拟目录 如 URL http://mockte.com/1 ...
- 关于ASP.NET中Request.QueryString的乱码问题(转)
转自 http://www.cnblogs.com/chinhr/archive/2008/09/23/1296582.html 今天在使用Request.QueryString的时候,发现所有接收到 ...
- asp.net中C#对象与方法 属性详解
C#对象与方法 一.相关概念: 1.对象:现实世界中的实体 2. 类:具有相似属性和方法的对象的集合 3.面向对象程序设计的特点:封装 继承 多态 二.类的定义与语法 1.定义类: 修饰符 类名称 ...
随机推荐
- Android之MaterialDesign应用技术
PS:纵观现在大大小小软件的界面都变的比较漂亮,还有一些系统了,比如小米的MIUI,华为的EMUI等,虽然底层都是安卓,但他们的界面多多少少都会不同,谷歌对这个UI也是非常重视的,MaterialDe ...
- ADO.NET复习总结(3)--参数化SQL语句--防止sql注入式攻击
1.SQL 注入 2.使用参数化的方式,可以有效防止SQL注入,使用类parameter的实现类SqlParameter Command的属性parameters是一个参数集合. 3.举例<查询 ...
- DotNetCore 定时服务 HangFire
最近在写一个Asp.net core 的项目,其中有用到定时任务,一开始准备要用Quartz.net.毕竟在Java中和.net framework中都表现突出. 但是看了一下Quartz.net 关 ...
- TCP是什么? 最简单的三次握手说明
TCP是什么? TCP(Transmission Control Protocol 传输控制协议)是一种面向连接(连接导向)的.可靠的. 基于IP的传输层协议.TCP在IP报文的协议号是6.TCP是一 ...
- Performance Testing 前期准备以及场景设计
性能测试的session参加过几个,也查阅了很多相关的资料.年前被分配了测试任务,一直拖到现在,准备开始做的时候,才发现真的是不知道如何做起啊.今天和同事聊了一下,有很大启发.测试小白一枚,只分享一下 ...
- Linkin大话Java和internet概念
整理电脑,无意中翻到不知道哪里来的文章,觉得里面写的很好,仔细看过一遍后,整理了下贴了出来,其中的好多概念我觉得讲的很透彻. 既然Java不过另一种类型的程序设计语言,为什么还有这么多的人认为它是计算 ...
- linkin大话设计模式--模板方法模式
linkin大话设计模式--模板方法模式 准备一个抽象类,将部分逻辑以具体方法的形式实现,然后申明一些抽象方法来迫使子类实现剩余的逻辑.不同的子类可以以不同的方式实现这些抽象方法,从而对剩余的逻辑有不 ...
- 使用TransactionScope做分布式事务协调
//场景是使用在多个数据库之间的协调,.NET 2.0使用一个新的类型 TransactionScope来进行协调,这与之前的COM+协调是相对来说更加方便的 //需要引用一个新的程序集:System ...
- 【转】shell学习笔记(四)——条件测试
1 test 条件检测 当我要检测系统上面某些文件或者是相关的属性时,利用 test 这个命令来工作真是好用得不得了, 举例来说,我要检查 /home/oracle/zy是否存在时,使用: test ...
- HTML学习——表单标签
1.type: 当 type="radio" 时,控件为单选框 当 type="checkbox" 时,控件为复选框 2.value:提交数据到服务器的值(后台 ...