每隔5分钟刷新一次asp.net mvc [英] refresh every 5 minutes en asp.net mvc

查看:107
本文介绍了每隔5分钟刷新一次asp.net mvc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控制器显示Excel工作表中的数据。
我需要控制器每隔1小时检查一次excel表,还应该更新视图。
这是我的控制器代码:

The controller display the data from the excel sheet. I need that the controller check the excel sheet every 1 hour, also the views should be updated. This is my controller code:

string path3 = "D:/Project/Sesame Incident Dump_20160317.xls";

Excel.Application application3 = new Excel.Application();
Excel.Workbook workbook3 = application3.Workbooks.Open(path3);
Excel.Worksheet worksheet3 = workbook3.ActiveSheet;
Excel.Range range3 = worksheet3.UsedRange;
List<SesameIncident> ListSesameIncident = new List<SesameIncident>();
for (int row = 2; row <= range3.Rows.Count; row++)
{
    SesameIncident S = new SesameIncident();
    S.Number = (((Excel.Range)range3.Cells[row, 1]).Text);
    S.AssignedTo = (((Excel.Range)range3.Cells[row, 5]).Text);
    S.Opened = (((Excel.Range)range3.Cells[row, 6]).Text);
    S.Status = (((Excel.Range)range3.Cells[row, 7]).Text);
    S.Priority = (((Excel.Range)range3.Cells[row, 10]).Text);
    S.AssignedGroup = (((Excel.Range)range3.Cells[row, 12]).Text);

    ListSesameIncident.Add(S);

}

ViewBag.ListSesameIncidents = ListSesameIncident
       .Where(x => x.Status == "Pending Customer").Take(13);


推荐答案

您可以添加标题到控制器中的 HttpContext.Response

You can add a Header to your HttpContext.Response in your controller

HttpContext.Response.Headers.Add("refresh", "300; url=" + Url.Action("Index"));

这篇关于每隔5分钟刷新一次asp.net mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆