ASP. NET storage status

Source: Internet
Author: User

Generally, ASP. NET stores session states in three ways: inproc, StateServer, and sqlserver. In this case, you can use a syntax similar to this to store the session state: session ["key"] = Val. Val can be any type of object.

However, if StateServer or sqlserver is used, the Val type must be a serializable type, because the ASP. NET application must serialize the object when data is exchanged between status servers. If Val is not serializable (the private domain/attribute is not specified and the custom serialization feature is not specified), the following exception occurs during runtime:

"/"ApplicationProgramServer error.


Unable to serialize session status. In "StateServer" Or "Sqlserver" Mode, ASP. NET The session state object is serialized, so it is not allowed to use objects that cannot be serialized or Marshalbyref Object. If the custom session status is stored in "Custom" If similar serialization is executed in the mode, the same restrictions apply.

There are several solutions:

1. Try to use basic types of objects to store data

2. Only public domains/attributes are used for custom types.

3. Implement serialization for custom types

......

the advantages and disadvantages of these methods are not described. I was lazy and used the first one.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.