我理解,这个问题在StackOverflow上也存在类似问题,但没有任何问题解决了我的问题,因此产生了一个新的问题。
如标题所示,在用户复读一页时,我想发现。 我有一页,可以节省一些关于用户所做工作的记录信息(如添加、删除或替换物品)。 只有当用户离开网页时,而不是通过更新这一记录,才能保存这一记录。
我尝试了以下例子,以发现它是否再次提出或提出新的要求:
public ActionResult Index()
{
var Model = new Database().GetLogInfo();
var state = TempData["refresh"];
if(state == null)
{
//This is a mock structure
Model.SaveLog(params);
}
TempData["refresh"] = true; //it can be anything here
return View();
}
Considering it s a TempData
it should expire on my next action. However, it s surviving the entire application for some reason. According to this blog it should expire on my subsequent request (unless i m not understandig something). Even if i log out from my app and log in again, my TempData is still alive.
I ve been thinking about use the javascript function onbeforeunload
to make an AJAX call to some action, but once again i d have to rely on TempData or to persist this refresh info somehow. Any tips?