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.定义类: 修饰符 类名称 ...
随机推荐
- vue学习笔记(三)——目录结构介绍
1.初始目录结构如下: 2.目录结构介绍 目录/文件 说明 build 最终发布的代码存放位置. config 配置目录,包括端口号等.我们初学可以使用默认的. node_modules npm 加载 ...
- struts异常:Caused by: Parent package is not defined: json-default - [unknown location]解决办法
问题描述: Unable to load configuration. - [unknown location] at com.opensymphony.xwork2.config.Configura ...
- eclipse出现错误:he type java.util.Map$Entry cannot be resolved. It is indirectly referenced
eclipse出现错误:he type java.util.Map$Entry cannot be resolved. It is indirectly referenced jre 换成6的就好了选 ...
- MySQL zip解压版安装过程及问题
1.首先解压mysql压缩包,然后添加环境变量path(D:\mysql-5.7.11\bin) 2.修改D:\mysql-5.7.11\my-default.ini 文件的配置项 ...
- nginx中location匹配顺序
一.location语法 语法: Syntax: location [ = | ~ | ~* | ^~ ] uri { ... } location @name { ... } Default: - ...
- 免费内网映射外网绑定,tcp端口转发(windows)
在tcp socket开发过程中,想要外网客户端映射到本地启动的tcp服务端,总结本地tcp端口映射外网方法: 1.打开ngrok后注册用户,网址 ngrok:https://www.ngrok.cc ...
- SpringMVC的filter怎么使用Autowired依赖注入bean
有的时候根据我们业务的需要,我们需要在web项目中定义一个自己的filter,并想在这个filter中使用@Autowired注入bean供我们使用.如果直接使用的话是不行的,需要我们在xml文件 ...
- mysql-innoDB-锁
在InnoDB加锁前,为什么要先start transaction innodb下锁的释放在事务提交/回滚之后,事务一旦提交/回滚之后,就会自动释放事务中的锁,innodb默认情况下autocommi ...
- 申请9位数QQ
官网:QQ注册第一步:下面手机号不要填写 第二步:验证 第三步:开始填写手机号 注:不行就多试着几次就可以了,是不是很惊喜啊!(漏洞,被腾讯发现就不行了喽)
- FastDFS分布式存储实战
<FastDFS分布式存储实战> 技术选型 FastDFS相关组件及原理 FastDFS介绍 FastDFS架构 FastDFS工作流程 上传 同步机制 下载 文件合并原理 实验环境说明 ...