简体   繁体   English

5分钟后(不同的页面)ASP.NET MVC强制页面重定向

[英]ASP.NET MVC Forcing Page Redirect After 5 Minutes (Different Pages)

I am building a gallery website that allows visitors to view different photographs. 我正在建立一个画廊网站,使访客可以查看不同的照片。 I want to require visitors to register once they spend more than 5 minutes on the website. 我想要求访客在网站上停留超过5分钟后就进行注册。 This includes page redirections . 这包括页面重定向 So, I am trying to come up with a way to redirect visitors to my registration page and disallow any further photography viewing until they make an account. 因此,我尝试提出一种将访问者重定向到我的注册页面的方法,并禁止任何进一步的摄影作品浏览,直到他们建立帐户为止。

JS code like the following only keeps track of the currently active page: 如下所示的JS代码仅跟踪当前活动的页面:

var delay = 1000; 
setTimeout(function(){ window.location = URL; }, delay);

Is there any way to keep track of the visitor's overall time-spent? 有什么方法可以跟踪访客的总时间吗? And force a page redirection if the time exceeds 5 minutes? 如果时间超过5分钟,并强制进行页面重定向?

Any guidance will be highly appreciated. 任何指导将不胜感激。 Thanks. 谢谢。

window.setTimeout(window.location.href = "https://www.google.co.in",300000 );

在页面加载或窗口加载中使用以上代码。(5min = 300000ms)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM