zoukankan      html  css  js  c++  java
  • Request.ServerVariables(HTTP_REFERER)

    作用:得到访问的上一页的Url
    Request.ServerVariables["HTTP_REFERER"]可用的情况
    1.直接用<a href>
    2.用Submit或<input type=image>提交的表单(POST or GET)
    3.使用Jscript提交的表单(POST or GET)

    Request.ServerVariables["HTTP_REFERER"]不可用的情况
    1.从收藏夹链接
    2.单击'主页'或者自定义的地址
    3.利用Jscript的location.href or location.replace()
    4.在浏览器直接输入地址
    5.<%Response.Redirect%>
    6.<%Response.AddHeader%>或<meta http-equiv=refresh>转向
    7.用XML加载地址
    Asp.net  示例
    public partial class FileManage_EditSoftWare : System.Web.UI.Page
    {
        private static string strLastPageUrl = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                strLastPageUrl = Request.ServerVariables["HTTP_REFERER"].ToString();
            }
        }
      //返回
        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Response.Redirect(strLastPageUrl);
        }
    }
  • 相关阅读:
    学习进度条08
    学习进度条07
    子数组和最大值(二维)
    学习进度条06
    构建之法阅读笔记04
    四则运算网页版
    泛型代码中的默认关键字
    js 日期大小比较
    c#Reverse字符串
    c#获取数组中指定元素的索引
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/904074.html
Copyright © 2011-2022 走看看