【发布时间】:2018-12-24 03:03:14
【问题描述】:
我有一个 MVC 视图,它呈现多个局部视图和两个动作。在这种情况下,有时我们会遇到页面无响应问题。 那么我可以根据 View 的整体性能实现任何操作过滤器类型的解决方案吗?
基本上,只要此视图花费超过 30 秒,我就想重定向到自定义页面。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-3 model-view-controller
我有一个 MVC 视图,它呈现多个局部视图和两个动作。在这种情况下,有时我们会遇到页面无响应问题。 那么我可以根据 View 的整体性能实现任何操作过滤器类型的解决方案吗?
基本上,只要此视图花费超过 30 秒,我就想重定向到自定义页面。
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-3 model-view-controller
如果 U R 使用 web.config 文件为每个页面设置空闲超时
<system.web>
<sessionState timeout="20" mode="InProc" />
.....
<authentication mode="Forms">
<forms loginUrl="~/" slidingExpiration="true" timeout="20" />
</authentication>
上述设置称为服务器端设置,并在 20 分钟后将页面重定向到特定页面。
或
U 可以使用相同的客户端脚本。使用可以在每次页面加载时运行的以下 javascript 代码。
SetTimeout(function()
{
window.location.href = "/"; // U can use @Url.Content("~/") inside the quotes to also or else give the page path to the page U want to redirect
}, 10 * 60 * 1000); // 10 mins * 60 sec/min * 1000 ms/sec. (set U R won timeout)
此代码会将某人在页面闲置 10 分钟后重定向到主页,或者需要更长的时间来加载内容。
【讨论】: