How can i change session when open url in another tab in asp.net
I am developing one web application in asp.net. I am opening my all pages on pop up window. I want to expire my session or change the session v开发者_高级运维alue when someone copy the url and paste it into another tab. How can i implement it ? Please help me out.
A simple way would be to check Request.UrlReferrer. The Referrer would be empty if the user copy pastes a URL.
A couple of points you should consider before using this:
- Provide exceptions for any pages that can be directly entered by the user. For e.g. the login page or a page that can be bookmarked
- I believe a pop can be opened from Javascript, without a referrer. Make sure your existing code is not using this method to open a pop up.
For a generic way to determine if the user has opened a new tab, see here
I have solved this problem by using this
string referer = Request.ServerVariables["HTTP_REFERER"];
if (string.IsNullOrEmpty(referer))
{
Response.Redirect("../Index.htm");
}
精彩评论