如何获取上一页网址 [英] how to get previous page url

查看:97
本文介绍了如何获取上一页网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要获取上一页URL,我已使用此代码....

to get previous page url i have used this code....

string referrerurl = request.urlreferrer.tostring();



但不能在IE6中使用....


谁能帮我.............


谢谢



but not working in IE6....


can anyone help me.............


Thanks

推荐答案


String referer = Request.UrlReferrer.ToString();



要记住的一件事是,当您发回到服务器时,UrlReferrer将更改为您的页面名称.因此,如果您想将用户重定向到上一页,则应该将值存储在页面的第一页加载中的ViewState中.在几次回发到同一页面后.



One thing to remember is that UrlReferrer will change to your pagename when you post back to the server.. so you should maybe store the value in ViewState on the first page load of the page if you are wanting to redirect the user to the previous page after a couple postbacks to the same page.

if( !IsPostBack )
{
 ViewState["PreviousPageUrl"] = Request.UrlReferrer.ToString();
}



它起作用的情况包括浏览器加载URL的以下方法:

点击直接的HTML< a href>链接;
使用POST或GET从提交按钮< input type = image>提交表单.或客户端脚本(form.submit())

无法正常工作的情况:

使用Response.Redirect/Server.Transfer;
单击收藏夹",历史记录"或最近输入的URL列表;
在IE的工具栏中单击主页",或在IE的链接"工具栏中单击一个项目;
在客户端JScript/JavaScript/VBScript中使用location.href或location.replace();
使用HierMenus(详细信息);
直接在浏览器中输入URL,然后按Enter或单击转到";
从电子邮件或MS Office文档启动可点击的URL;
使用Response.AddHeader或< meta http-equiv = refresh>重定向;
使用XML加载URL



The situations where it does work include the following methods of a browser loading a URL:

clicking on a straight HTML <a href> link;
submitting a form, using POST or GET, from a submit button, <input type=image> or client-side script (form.submit())

The situations where it doesn''t work:

using Response.Redirect / Server.Transfer;
clicking on a Favorite, History, or the recently-typed URLs list;
clicking on ''Home'' in IE''s toolbar, or an item in IE''s ''Links'' toolbar;
using location.href or location.replace() in client-side JScript/JavaScript/VBScript;
using HierMenus (details);
typing the URL directly in the browser and hitting Enter or clicking ''Go'';
launching a clickable URL from an e-mail or MS Office document;
using Response.AddHeader or <meta http-equiv=refresh> to redirect;
loading the URL with XML


这篇关于如何获取上一页网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆