简体   繁体   English

会话ASP.NET MVC上的本地存储或服务器端会话?

[英]Session Local Storage or Server side session at ASP.NET MVC?

I have list of Objects containing no sensitive data ( ie simple settings of a widget at client side 5-6 integer values and Guid, probably multiple widgets at the same time). 我有不包含敏感数据的对象列表(即,客户端5-6整数值和Guid的小部件的简单设置,可能同时有多个小部件)。

At the moment, I am using ASP.NET MVC Session. 目前,我正在使用ASP.NET MVC会话。 It doesn't seems to be relieable. 它似乎并不可靠。 It is getting null time to time for certain keys those are stored inside that. 存储在其中的某些密钥正变得不时空。 It happens when I launch application at debugging or Network is slow. 当我在调试时启动应用程序或网络速度很慢时,就会发生这种情况。

Can I use Client side session Storage for storing all settings? 我可以使用客户端会话存储来存储所有设置吗? ( ie sessionStorage or localStorage ). (即sessionStorage或localStorage)。

I am concerned about IIS re-cycling which causes session to remove or any server side exception. 我担心IIS回收会导致会话删除或任何服务器端异常。

Edit 编辑

public ActionResult ApplySettingsForDashboard(DashboardCommonSettings settings)
{
  Session[string.Concat("SettingsToApply_",settingsToApply.PanelGuid)]=settings;
}

public DashboardCommonSettings GetSettingsFromSession(string PanelGuid)
{
    var settings = Session[string.Concat("SettingsToApply_",PanelGuid)]
}

Comments and suggetions are welcomed. 欢迎提出意见和建议。 Thanks 谢谢

On the basis of comments, I want to answer in a way : Use Out-Proc Session storage ( persistent storage ) for reliable session storage as much as possible. 根据评论,我想以一种方式回答:尽可能使用Out-Proc会话存储(持久性存储)进行可靠的会话存储。 It would be slow, so need to be used cautiously. 这会很慢,因此需要谨慎使用。 In-Proc session storage is highly unreliable specifically at production environment. 进程内会话存储特别在生产环境中非常不可靠。 Either localStorage ( client side ) can be taken as an option when we don't have sensitive data. 当我们没有敏感数据时,可以将localStorage(客户端)作为选项。

Other answers are also welcome. 也欢迎其他答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM