Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

c# - ASP.NET Session size limitation

Is there some kind of Session size limitation or advisable value to not to surpass ?

In my web application I create a few DataTables to store user selections which are stored in session until user approves selections so I add those values to database.

The problem is that I don't know whether session is reliable enough to keep few objects in or not ?

Thanks!

more info

Session size is about 10-20KB max.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here's a few notes about Session state:

  • InProc (mode="InProc") session state is limited to the amount of memory available to the worker process. Only object references are stored, not the objects themselves.

Out of process state management serialises objects before persisting them:

  • Out of Process state management using the session state server (mode="StateServer") is limited to the amount of memory available to the state service.

  • Out of Process state management using SQL Server (mode="SQLServer") is bound only by the maximum size of the SQL image data type or the maximum permitted size of the database.

Obviously there still has to be enough memory available to the worker process to be able to pull an out of session object back into memory and re-hydrate for the duration of the http request.

As I mentioned previously, out of process state management serialises objects before persisting them.

This means that objects must be serialisable which excludes, for example, XmlDocument or anything that inherits from MarshalByRef.

Attempting to serialise objects of this sort will result in the following exception:

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...