简体   繁体   English

最小化浏览器时,asp mvc每30秒重新加载一次页面

[英]asp mvc reload page every 30 seconds when browser is minimized

Actually we Play a notification sound when some update happens in database, so I am trying to reload a ActionMethod every 30 seconds when browser in minimized, this works fine in Firefox , but in Chrome this doesn't work. 实际上,当数据库中发生某些更新时,我们会播放通知声音,因此,当浏览器最小化时,我试图每30秒重新加载一个ActionMethod ,这在Firefox中效果很好,但在Chrome中不起作用。

Scenario: 场景:

Minimize the browser and leave the computer idle. 最小化浏览器并使计算机空闲。

I have tried two methods: 我尝试了两种方法:

Method 1: 方法1:

   <meta http-equiv="refresh" content="30;URL=http://example.com/" />

Method 2: 方法2:

 <script>

   $(document).ready(function () {

   setTimeout(function(){
    window.location.reload(1);
    }, 30000);

    });

 </script>

After reading this post , It seems when Chrome is minimized it sets Javascript setInterval and setTimeout to an idle state, because browser performance improvements affects the executions of Javascript intervals. 阅读本文后,似乎将Chrome最小化时,它将Javascript setIntervalsetTimeout设置为空闲状态,因为浏览器性能的提高会影响Javascript间隔的执行。

So Can i use Scheduled Tasks like FluentScheduler , Quartz.NET or Hangfire to reload a ActionMethod every 30 seconds ? 那么,我可以每30秒使用FluentScheduler,Quartz.NET或Hangfire之类的计划任务来重新加载ActionMethod吗?

Any help would be great. 任何帮助都会很棒。

SignalR is a perfect match here. SignalR在这里非常适合。 Why do you want your clients to be sending request to the server every 30 seconds? 为什么要让客户每30秒将请求发送到服务器一次? This is likely to hit your performance and increase your server load. 这可能会影响您的性能并增加服务器负载。

Instead I would suggest using SignalR and pushing notification to the client whenever there is any update. 相反,我建议您使用SignalR并在有任何更新时将通知推送到客户端。

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

相关问题 ASP.NET MVC每45秒响应缓慢 - asp.net mvc slow response every 45 seconds ASP.NET MVC控制器在上载Blob时导致页面重新加载 - ASP.NET MVC Controller causing page reload when uploading a Blob 在ASP.Net MVC中使用布局页面时,是否在每次调用新页面时加载布局? - When using a layout page in ASP.Net MVC is the layout loading every time a new page is called? 如果整个页面在MVC中花费30秒以上,则重定向到自定义视图 - Redirect to custom view in case overall page takes more than 30 seconds in MVC 在Safari中使用浏览器后退按钮时,从浏览器缓存中重新加载了Asp.net MVC视图/页面 - Asp.net mvc view/page reloaded from browse cache when using browser back button in Safari ASP.NET MVC应用程序身份验证每20-50秒丢失一次 - Asp.net mvc application authentication lost every 20-50 seconds ASP.Net MVC如何每10秒调用一次操作方法 - ASP.Net MVC how to invoke the action method every 10 seconds 如何使用c#asp.net MVC每10秒调用一次方法? - How to call a Method every 10 seconds with c# asp.net MVC? 提交 MVC 表单时抓取表单值以避免页面重新加载 - Grab form values to avoid page reload when submitting a MVC form 在每次页面刷新时重新加载数据表 - Reload DataTable on Every Page Refresh
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM