您的位置:首页 > 理论基础 > 计算机网络

Request.ServerVariables(HTTP_REFERER)&数据提交时注意的问题

2013-10-07 11:21 531 查看
来自:/article/4730847.html 特此感谢

作用:得到访问的上一页的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);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐