gpt4 book ai didi

asp.net - 当 session 状态设置为 Sql Server 时,使用什么序列化程序?我可以更改它吗?

转载 作者:行者123 更新时间:2023-12-02 06:26:22 24 4
gpt4 key购买 nike

我们想要使用 Sql Server session 状态,但我们已经设计了许多对象,以便通过使用 DataContractSerializer 的 WCF 进行序列化。我不知道 Sql Server session 状态使用什么序列化器,但如果它是 XmlSerializer,那么我担心它可能无法按照我们对象的设计方式工作。

有谁知道它使用哪个序列化器以及是否可以更改?

最佳答案

看起来无法更改。看这个info from MSDN .

To perform data serialization and deserialization, ASP.NET uses two methods depending on the types involved. For basic types, ASP.NET resorts to an optimized internal serializer; for other types, including objects and user-defined classes, ASP.NET makes use of the .NET binary formatter. Basic types are String, DateTime, Boolean, byte, char, plus all numeric types. For these types, a tailor-made serializer is used that is faster than the default and general-purpose .NET binary formatter.

The optimized serializer is neither publicly available nor documented. It is nothing more than binary read/writer and employs a simple but effective storage schema. The serializer uses the BinaryWriter class to write out one byte to denote the type and then the value. While reading serialized bytes, the class first extracts one byte, detects the type of the data to read, and then resorts to a type-specific ReadXxx method on the BinaryReader class.

看起来它没有序列化为 XML。只是二进制。尽管请注意,这是 2003 年写的,十多年前了!

关于asp.net - 当 session 状态设置为 Sql Server 时,使用什么序列化程序?我可以更改它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24705131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com