What does enableSessionState=ReadOnly actually do?
.NET blocks a page from loading if it accesses Session while that user (session user) is loading another page that also accesses session.
To get around this, if you still need to read session variables you can set enableSessionState="ReadOnly":
<%@ Page EnableSessionState="ReadOnly"
But can you write to session if enableSessionState="ReadOnly"? The answer is yes - but the data will only persist for that single request.
This means that if you have code in a 'base page', singleton, or other static helper file that caches data to session you do not necessarily need to rewrite it when setting readonly. Instead just make sure that you can handle the condition where the value is null on later requests, even though you set it.
Note that multiple readers are allowed simultaneously, but no reader or writer can gain access if any writer holds a lock! Therefore, keep the pages that are set to write to the global session (not in readonly mode) to a minimum! If you have your page set to readonly, now any other reader and at most one other writer can gain access to session and render while your page is processing. Technically the writer cannot access session if a reader has a reader lock, but this appears to be a very short lock (while actually reading the session itself), not a lock over the entire page request.
Of course, if you can disable session altogether, that's even better.
Created By: amos 11/5/2014 11:16:16 AM
Updated: 11/5/2014 12:33:57 PM