Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果用户在asp.net中单击浏览器后退按钮,如何清除/放弃会话_C#_Asp.net_.net_Session_Session State - Fatal编程技术网

C# 如果用户在asp.net中单击浏览器后退按钮,如何清除/放弃会话

C# 如果用户在asp.net中单击浏览器后退按钮,如何清除/放弃会话,c#,asp.net,.net,session,session-state,C#,Asp.net,.net,Session,Session State,需要清除浏览器后退按钮上的会话(重定向到登录或错误页面),如果用户再次在浏览器中粘贴相同的URL以访问网页或单击浏览器前进按钮,因为会话已过期/放弃,所以重定向到登录或错误页面。任何时候都不应从浏览器缓存中显示相同或任何应用程序网页 技术堆栈: Microsoft.NET Java脚本/C# IE7/8/9/10 铬 狩猎 Mozilla 不幸的是,大多数现代浏览器在用户单击“上一步”按钮后会从缓存中重新加载页面。没有向服务器发送请求 您可以尝试通过在html标题部分中添加元信息来禁用缓存:

需要清除浏览器后退按钮上的会话(重定向到登录或错误页面),如果用户再次在浏览器中粘贴相同的URL以访问网页或单击浏览器前进按钮,因为会话已过期/放弃,所以重定向到登录或错误页面。任何时候都不应从浏览器缓存中显示相同或任何应用程序网页

技术堆栈:

  • Microsoft.NET
  • Java脚本/C#

  • IE7/8/9/10

  • 狩猎
  • Mozilla

不幸的是,大多数现代浏览器在用户单击“上一步”按钮后会从缓存中重新加载页面。没有向服务器发送请求

您可以尝试通过在html标题部分中添加元信息来禁用缓存:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />


但请记住,浏览器决定从缓存中重新加载哪些内容以及再次请求哪些内容。

不幸的是,大多数现代浏览器会在用户单击“上一步”按钮后从缓存中重新加载页面。没有向服务器发送请求

您可以尝试通过在html标题部分中添加元信息来禁用缓存:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />


但请记住,浏览器决定从缓存中重新加载哪些内容以及再次请求哪些内容。

不幸的是,大多数现代浏览器会在用户单击“上一步”按钮后从缓存中重新加载页面。没有向服务器发送请求

您可以尝试通过在html标题部分中添加元信息来禁用缓存:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />


但请记住,浏览器决定从缓存中重新加载哪些内容以及再次请求哪些内容。

不幸的是,大多数现代浏览器会在用户单击“上一步”按钮后从缓存中重新加载页面。没有向服务器发送请求

您可以尝试通过在html标题部分中添加元信息来禁用缓存:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />


但请记住,浏览器决定从缓存重新加载哪些内容以及再次请求哪些内容。

我认为禁用缓存不是一个好主意。对您来说唯一重要的是,用户必须登录并在点击导航按钮时重新开始。您需要有一个注销页面,该页面可以执行注销和清除会话所需的任何操作,然后在用户离开时重定向到该页面

$(window).bind('beforeunload', function (event) {
   //if(some condition that detects user hasn't clicked a link on your page)
       location.href = "/signout.aspx";
}

我认为禁用缓存不是一个好主意。对您来说唯一重要的是,用户必须登录并在点击导航按钮时重新开始。您需要有一个注销页面,该页面可以执行注销和清除会话所需的任何操作,然后在用户离开时重定向到该页面

$(window).bind('beforeunload', function (event) {
   //if(some condition that detects user hasn't clicked a link on your page)
       location.href = "/signout.aspx";
}

我认为禁用缓存不是一个好主意。对您来说唯一重要的是,用户必须登录并在点击导航按钮时重新开始。您需要有一个注销页面,该页面可以执行注销和清除会话所需的任何操作,然后在用户离开时重定向到该页面

$(window).bind('beforeunload', function (event) {
   //if(some condition that detects user hasn't clicked a link on your page)
       location.href = "/signout.aspx";
}

我认为禁用缓存不是一个好主意。对您来说唯一重要的是,用户必须登录并在点击导航按钮时重新开始。您需要有一个注销页面,该页面可以执行注销和清除会话所需的任何操作,然后在用户离开时重定向到该页面

$(window).bind('beforeunload', function (event) {
   //if(some condition that detects user hasn't clicked a link on your page)
       location.href = "/signout.aspx";
}
可能的重复可能的重复可能的重复可能的重复