将字符串存储在会话变量中,其中模式为 StateServer
如果我在会话变量中存储字符串值,是否需要序列化或反序列化它? 我读到,当您在 web.config
中使用时,
<sessionState mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
stateNetworkTimeOut="60"
/>
您需要先进行序列化,然后才能将值存储在会话变量中,然后在检索该值时进行反序列化。 我想知道,例如,您是否只需将字符串值放入会话中,例如:
Session("MyStringVar") = "MyStringValue"
当您检索它时,您可以这样做:
DIm strVal as String
strVal = Ctype(Session("MyStringVar"), String)
另外,指定的超时是 60,是以分钟还是小时为单位?
谢谢。
If I store a string value in my session variable, do I need to serialize or deserialize it? I read that when you use in your web.config
<sessionState mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
stateNetworkTimeOut="60"
/>
You need to serialize before you can store the value in session variable and you would then deserialize when you retrieve the value. I wonder if for example, you just place the string value to a session like:
Session("MyStringVar") = "MyStringValue"
and when you retrieve it, you could just do:
DIm strVal as String
strVal = Ctype(Session("MyStringVar"), String)
Also, is the timeout specified for that is 60, is it in minutes or hours?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不会。.net 运行时会处理所有这些事情。
但是,如果您要存储未标记为可序列化的对象,则需要执行自己的序列化。 另外,超时值以分钟为单位。
No. the .net runtime will take care of all of that.
However, you would need to do your own serialization if you were storing an object that wasn't marked as serializable. Also, The timeout value is in minutes.
对于 web.config 您应该能够执行以下操作:
对于 Session 和字符串值,您可以执行以下操作,如果它不是字符串,请将字符串替换为对象类型...:
For the web.config you should be able to do:
For the Session and a string value you can do, if its not a string, replace string with object type...: