IFRAME保持活动功能

编程入门 行业动态 更新时间:2024-10-19 17:21:48
本文介绍了IFRAME保持活动功能 - 复位会话超时需要什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个隐藏的iframe的刷新飘飞,为了保持ASP.NET会话启动和运行,只要用户在线。

I have a hidden iframe that refreshes every now and then, in order to keep the ASP.NET session up and running, for as long as the user is online.

不过,我一直在让用户体验会话超时的报告,所以现在我在需要重置会话计时器什么疑问的。

However, I have been getting reports of users experiencing session timeouts, so now I am in doubt of what is needed to reset the session timer.

隐藏的iframe的内容页(简单的HTML页)刷新本身以一定的时间间隔,这比会话超时少显著

The hidden iframe's content page (simple html page) refreshes itself at a certain interval, which is significantly less than the session timeout.

我的问题是:是否足够(用于会话计时器重置),让网页自动刷新,甚至当服务器响应一个HTTP / 1.x的304未修改?

My question is: Is it enough (for the session timer to reset) to let the page refresh itself, even when the server responds with a HTTP/1.x 304 Not Modified?

时它只是告诉web服务器的GET请求本身重置会话计时器?

Is it simply the GET request itself that tells the webserver to reset the session timer?

或者我需要确保实际读取页面和接收HTTP / 1.x的200 OK响应?

Or do I need to make sure to actually fetch the page and receive a HTTP/1.x 200 OK response?

推荐答案

所有你需要做的,以保持会话活着就是从当前会话发送到页面的请求。您可以通过内部框架做到这一点,还是通过AJAX。

All you have to do to keep the session alive is send a request to a page from the current session. You can do this via iframes, or via ajax.

如果您只需刷新页面在iframe,响应可缓存一 - 因此,304你必须每次发送一个新的要求 -

If you simply refresh the page in the IFrame, the response may be a cached one - thus the 304. You have to send a fresh request every time -

var url = "domain/defibrillator.aspx?" + (new Date()).getTime();

例如

domain/defibrillator.aspx?1556467987987 domain/defibrillator.aspx?5448796497878 domain/defibrillator.aspx?4123165487987 ....

编辑1

或者你也可以使用刷新HTTP头属性。

如果您使用的是上面提到的$ C $的CProject文章,然后尝试使用,而不是内部框架AJAX来模拟它 - 它会为你节省额外的iframe标记的几个字节

If you are using the codeproject article mentioned above, then try to model it using AJAX instead of iframes - it would save you a few bytes of extra iframe markup.

如果客户机已经执行了  有条件的GET请求和访问  允许的,但该文件没有被  修改,服务器应该响应  与此状态code。 304  响应不能包含一个  消息主体,并因此总是  通过第一个空行结束  之后头字段。

If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.

这意味着该请求还没有达到ASP.NET管道,并已直接被由IIS本身提供。 ASP.NET环境不知道的请求已经取得进展。因此,它不会执行会话续订。

This means that the request hasn't reached the ASP.NET pipeline, and has directly been served by IIS itself. ASP.NET environment doesn't know that a request has been made. So, it won't perform the session renewal.

更多推荐

IFRAME保持活动功能

本文发布于:2023-10-31 16:11:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   IFRAME

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!