I am trying to display a countdown timer in view. After time is out, user should be redirected to another page. The code below of course doesn't work, but it should clarify a bit what I aim for:
@{
int txt = (int)TempData["txt"];
DateTime st = (DateTime)HttpContext.Current.Session["start"];
DateTime nw = DateTime.Now;
TimeSpan es = nw - st;
}
@switch(txt)
{
case 1:
@Html.Partial("_Text1", Model)
break;
case 2:
@Html.Partial("_Text2", Model)
break;
}
<p>@es.ToString("mm:ss")</p>
So when the user opens the page for the first time, timer should start and be visible while user switches between subviews _Text1 and _Text2 (each subview has a link to another). When timer reaches 00:00, RedirectToAction should be invoked. If possible, I would like to avoid using JScript or any solution that a user can disable/overcome with browser settings.