[英]how can i refresh automaticly View page on MVC4
I'm building a web page using MVC. 我正在使用MVC构建网页。 I want to refresh my entire view every 30 seconds i know about but I'm looking for somthing more elegant.
我想每30秒刷新一次我的整个视图,但是我正在寻找更优雅的东西。
I have a regular Controller and regular View like this: 我有一个像这样的常规控制器和常规视图:
Controller: HomeController 控制器:HomeController
View: Index 查看:索引
If you want to refresh the whole page, Use meta tag <meta http-equiv="refresh"
in your header/ 如果要刷新整个页面,请在页眉/中使用元标记
<meta http-equiv="refresh"
<head>
<title></title>
<meta http-equiv="refresh" content="5" />
</head>
<body>
...
</body>
or you could try to add a response header in your controller action: 或者您可以尝试在控制器操作中添加响应标头:
public Result Index()
{
Response.AddHeader("Refresh", "5");
return View();
}
You could reset a form from the javascript code: 您可以通过javascript代码重置表单:
this.form.reset();
After setting a timer on it. 设置好定时器之后。 Though in the majority of cases there is no need to refresh the whole view - please think whether you really need to refresh the whole view or only certain parts of this (which makes the whole refresh operation more user-friendly and faster).
尽管在大多数情况下并不需要刷新整个视图-请考虑您是否真的需要刷新整个视图或仅刷新其中的某些部分(这会使整个刷新操作更加人性化和更快)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.