• What Session State providers are available in ASP.NET?
What are the pros and cons of each?
Answer Posted / munish
Three of the most important methods in a session state provider are GetItem, GetItemExclusive, and SetAndReleaseItemExclusive. The first two are called by SessionStateModule to retrieve a session from the data source. If the requested page implements the IRequiresSessionState interface (by default, all pages implement IRequiresSessionState), SessionStateModule's AcquireRequestState event handler calls the session state provider's GetItemExclusive method. The word "Exclusive" in the method name means that the session should be retrieved only if it's not currently being used by another request. If, on the other hand, the requested page implements the IReadOnlySessionState interface (the most common way to achieve this is to include an EnableSessionState="ReadOnly" attribute in the page's @ Page directive), SessionStateModule calls the provider's GetItem method. No exclusivity is required here, because overlapping read accesses are permitted by SessionStateModule.
In order to provide the exclusivity required by GetItemExclusive, a session state provider must implement a locking mechanism that prevents a given session from being accessed by two or more concurrent requests requiring read/write access to session state. That mechanism ensures the consistency of session state, by preventing concurrent requests from overwriting each other's changes. The locking mechanism must work even if the session state data source is a remote resource shared by several Web servers.
SessionStateModule reads sessions from the data source at the outset of each request, by calling GetItem or GetItemExclusive from its AcquireRequestState handler. At the end of the request, SessionStateModule's ReleaseRequestState handler calls the session state provider's SetAndReleaseItemExclusive method to commit changes to the data source, and release locks held by GetItemExclusive. A related method named ReleaseItemExclusive exists so that SessionStateModule can time out a locked session by commanding the session state provider to release the lock.
Is This Answer Correct ? | 0 Yes | 5 No |
Post New Answer View All Answers
What is view state and how it works in asp net?
what are the events raised in asp.net page life cycle?in which stage view state can be loaded?
Is asp.net and .net same?
Explain the code Access Security (CAS) in .net Framework?
Which is better union or union all?
How to implement form based authentication in asp.net application?
List the asp.net validation controls?
Differences between “dataset” and “datareader”.
Define web.config in .net?
What is validation in asp.net?
How does the cookies work in asp.net?
Define static constructor?
What is the purpose of App_Code folder in ASP.NET? Why we this?
Whats the difference between registerclientscriptblock, registerclientscriptinclude and registerclientscriptresource?
What is the file through which you can customize your asp.net application?