Requst相关属性
来源:互联网 发布:activiti 源码分析 编辑:程序博客网 时间:2024/06/06 19:16
一、REQUEST的RAWURL属性,和其它获取URL信息的各种方法比较
测试的url地址是http://www.test.com/testweb/default.aspx?id=1, 结果如下:
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?id=1
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx?id=1
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx
Response.Write("<b>Request.ApplicationPath:</b> " + Request.ApplicationPath + "<br>");
Response.Write("<b>Request.CurrentExecutionFilePath:</b> " + Request.CurrentExecutionFilePath + "<br>");
Response.Write("<b>Request.FilePath:</b> " + Request.FilePath + "<br>");
Response.Write("<b>Request.Path:</b> " + Request.Path + "<br>");
Response.Write("<b>Request.PathInfo:</b> " + Request.PathInfo + "<br>");
Response.Write("<b>Request.PhysicalApplicationPath:</b> " + Request.PhysicalApplicationPath + "<br>");
Response.Write("<b>Request.PhysicalPath:</b> " + Request.PhysicalPath + "<br>");
Response.Write("<b>Request.RawUrl:</b> " + Request.RawUrl + "<br>");
Response.Write("<b>Request.Url.AbsolutePath:</b> " + Request.Url.AbsolutePath + "<br>");
Response.Write("<b>Request.Url.AbsoluteUri:</b> " + Request.Url.AbsoluteUri + "<br>");
Response.Write("<b>Request.Url.Host:</b> " + Request.Url.Host + "<br>");
Response.Write("<b>Request.Url.LocalPath:</b> " + Request.Url.LocalPath + "<br>");
二、 Request.UrlReferrer详解
Request.UrlReferrer可以获取客户端上次请求的url的有关信息。
这样我们就可以通过这个属性返回到“上一页”,
示例如下
1. 首先在Page_load中获得并储存该信息
Page_load(object obj,EventArgs e)
{
if(!IsPostBack)
{
if(Request.UrlReferrer!=null) //
{
ViewState["UrlReferrer"]=Request.UrlReferrer.ToString();
}
}
}
l 页面回发后会改变Request.UrlReferrer,将其指向当前页面,所以需要进行判断:只有在第一次请求页面的时候才储存该信息
l 因为可能“上一次”的url不存在,所以需要进行判断,只有在Request.UrlReferrer存在的情况下才进行储存
2. 然后在返回函数中使用该信息
void Return()
{
if(ViewState["UrlReferrer"]!=null)
Response.Redirect(ViewState["UrlReferrer"].ToString();
}
在使用Request.UrlReferrer时还要注意:
1. 如果上一页面使用document.location方法导航到当前页面,Request.UrlReferrer返回空值
2. 如果有A,B两个页面,在浏览器中直接请求A页面,在A页面的中Page_Load事件中导航到B 页面,则 Request.UrlReferrer返回空。因为 在Page_load事件中页面还未初始化,所以无法记录当前页的信息,导航到b页面也就无法获得上一页面的信息
3. 点击刷新按钮不会改变Request.UrlReferrer
- Requst相关属性
- dojo学习日记(2)——1.dojo/requst/xhr用来处理post,get请求 2.attach-point属性
- javascript实现Requst
- UIScrollView相关属性属性
- 用Requst获取请求数据
- Spring MVC注解requst部分内容
- webx - requst context之session
- meta 标签相关属性
- log4j相关属性简介
- Request Url相关属性
- 媒体相关的属性
- cookie相关属性
- 事件及相关属性
- jQuery 的相关属性
- gstreamer video 相关属性
- 技能相关属性
- 时间相关属性
- TreePanel相关属性
- PHP写注册登录界面有关表单的低级错误
- intelij破解方法
- 回到顶部
- tomcat处理请求
- 测试博客
- Requst相关属性
- HTML标题处有一个小图片
- 组件属性
- wr720n v4 折腾笔记(四):安装inode客户端njitclient
- 拒绝纸上谈兵--萌新开发手册(踩坑分享之封装)
- webService 初解
- C# ListView 简单的搜索功能
- 响应式:在页面开头加入
- 通过tomcat7-maven-plugin插件启动java web项目一直失败