ASP.Net状态服务器 [英] ASP.Net State Server

查看:105
本文介绍了ASP.Net状态服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我希望使用ASP.Net会话存储来存储会话的值.如果愿意,可以将值或对象标记为可序列化,以便放置在商店中.

不幸的是,在运行代码时,屏幕上显示了未处理的异常错误.代码本身不会在调试中的任何时候失败.完整的实际错误消息是未标记"System.Xml,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089"中的未处理的异常类型" System.Xml.XmlDocument"作为可序列化的"

该问题可以追溯到xml文档的某些属性,由于会话存储区是二进制序列化,因此与xml文档不兼容.我已经解决了这个问题,方法是使xml文档成为字符串,然后再返回到xml.

我的问题是,有更好的方法吗?

Hi
I wish to use ASP.Net Session Store to store a value to session. The value or object if you prefer is marked as serializable in order to be placed within the store.

Unfortunately, when running the code I get an unhandled exception error being displayed to the screen. The code itself does not fail at any point in debug. The actual error message in full is "An unhandled exception occurred ''Type ''System.Xml.XmlDocument'' in Assembley ''System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' is not marked as serializable"

The problem has been traced back to some properties that are xml documents, which due to session store being binary serialization is not compatible with xml documents. I have overcome the problem by making the xml document a string and then turning back again to xml afterwards.

My question is this, is there a better way of doing this? Surely, I don''t need to go through all of this save something to session?

推荐答案

您好,您可以创建一个类作为返回变量,其中包含Xml文档,然后添加可序列化的声明.

Hi, you can create a class as your return variable that will contain the Xml document, then add a serializable declaration.

[Serializable()]
public class XmlReturnClass  {
   ///Declare Xml here
   ///....
   ///....
}



祝你好运!



Good luck!


这篇关于ASP.Net状态服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆