ASP MVC 存储页面状态以供以后恢复
我有一组相当复杂的 ASP MVC 控件,用于设置数据过滤器(帐户 ID 范围、成本范围、运营商、日期等)。这还会创建一个具有标准结果集类型对象的数据表对象。
用户可能会想离开页面然后再回来。我想恢复以前的过滤器控制状态并提取当前结果集。
存储用户会话状态的标准 ASP MVC 方法是什么?我确实可以访问 SQLServer 数据库。一种想法是将过滤器视图对象和当前结果存储在缓存中。
我不需要恢复会话访问之间的状态(他们关闭浏览器并在其他时间返回。)
I have a fairly complex ASP MVC set of controls that set a data filter (account ID range, cost range, carrier, dates etc). This also creates a data table object with the standard result set type object.
The user might wonder away from the page and then come back. I want to restore the previous filter control states and also pull the current result set.
What is the standard ASP MVC method for storing the user session state? I do have access to a SQLServer database. One idea is to store the filter view object and current result in the cache.
I do not need to restore the state between session visits (they close the browser and come back at another time.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
存储会话状态是正确的关键词。
http://msdn.microsoft.com/en-us/library/ms972429。
http://www.aspx devarticles.com/c/a/ASP/Maintaining-Session-State-With-ASP/
您只需获取会话状态变量并以某种方式存储它,然后以某种方式检索它。这可能需要大量工作,而且可能有一种内置方法可以实现这一点,因为您那里有 MS SQL Server。但我不知道如何连接这些东西,所以我将会话对象写入连接到数据库的对象流。您可以稍后查询。
编辑:
另一方面,既然您说您不需要在访问之间恢复它,也许您只是想让这个租约的期限比现在长很多。听起来他们好像超时了?让它再保持连接几个小时。除非他们关闭页面,否则如果浏览器删除了 cookie,他们将在前面获得新的登录信息。
Storing Session State is the right key word.
http://msdn.microsoft.com/en-us/library/ms972429.aspx
http://www.devarticles.com/c/a/ASP/Maintaining-Session-State-With-ASP/
You need to simply grab the session state variable and store it somehow, then retreive it somehow. That might be a lot of work, and there might be a built in way to make it happen since you have an MS SQL Server right there. But I dont know about hooking those things up, so I'd write the session object to an objectstream hooked into the database. You can query for it later.
EDIT:
On the other hand, since you said you don't need it to be restored between visits, maybe you just want to make the lease duration of this one a lot longer than it is. Sounds like they are timing out? Tell it to hang onto connections for a few more hours. Unless they close the page, theyll get a new logon at the front if the browser deleted cookies.
我相信您只想保留过滤器值而不是查询结果,对吧?如果是这样,您可能希望将它们保存到字符串中并将它们保留在 cookie 中。您也可以使用 asp 会话。会话存在一些可扩展性缺点,但它通常是最简单的选择。
I believe you just want to persist the filter values and not the query results right? If so, you may want to save those to a string and persist them in a cookie. You could use the asp session too. There are some scalability drawbacks with session, but it is often the simplest option.