7

EDIT (clarifying my question): Is there an API or method with which we can use the Out Of Process Asp.NET State Service from our own code or is that proprietary?

We are looking into implementing a custom session state module that re-uses the components of the module that comes stock with asp. Our main goal is to just prevent session locking (without changing the session state mode to ReadOnly). Is this possible?

One of the key pieces that we would like to make work is to be able to use the same Out of Proc Session storage provider (The ASP State service) that is used internally by .NET as we have a load-balanced environment that doesn't use sticky sessions.

I have dug into the code over in the reference source, and my findings are below. I am hoping somebody has a different utility that could potentially be used to integrate a custom session state module the ASP State Service.


The default session Module is System.Web.SessionState.SessionStateModule. This is a Sealed class. This class appears to be the only class that uses the SessionStateMode.StateServer enum value (which is specified in the web config).

When this flag is set, the module sets the _store variable to be a new System.Web.SessionState.OutOfProcSessionStateStore which is a Friend Sealed class.

I had initially had a few thoughts on how to do this, and because of the modifiers on the classes above I was unable to do these. Are there other approaches that could be taken?

  1. Instantiate a new System.Web.SessionState.SessionStateModule and reference the _store variable. This did not work, obviously because the _store variable is private.
  2. I tried creating a class which inherits from System.Web.SessionState.SessionStateModule but obviously since it is sealed that does not work.
  3. Looked at copying the code from the .NET framework code. Realized that would be a very poor decision.

Are there any options I am missing?

Dan Drews
  • 1,966
  • 17
  • 38
  • Since all is sealed and private, there's not much you can do but rewrite it. But, since a lot of code in InProc session state provider is precisely related to lock (and also performance counters that you may not need), I would use the reference source as a starting point, remove all unnecessary code and start from there. That should not be a huge work. An actually, when you write a session state provider, the difficult part is lock, so if you don't want it, it should not be more than 200/300 lines of code. – Simon Mourier Mar 18 '16 at 06:35
  • We are trying to do out of proc, not in proc. My real question (as I think about it further) is whether there is a way that i am missing to interface with the Asp.net State Service – Dan Drews Mar 18 '16 at 12:14
  • Oops. sorry. missed that one. But my answer remains essentially the same (although out of proc is a bit more complex because it has socket connection). – Simon Mourier Mar 18 '16 at 12:51
  • Can you go with WIF?? – Moumit Mar 24 '16 at 06:00

1 Answers1

-1

I would recommend you reading this topic: I just discovered why all ASP.Net websites are slow, and I am trying to work out what to do about it.

It provides some starting points and info on the session topic, especially locking problem.

If you look for custom implementation of session module you can look here: http://www.codeproject.com/Articles/11712/Custom-session-state-management-in-ASP-NET

Community
  • 1
  • 1
Lesmian
  • 3,932
  • 1
  • 17
  • 28
  • I have already read that topic. My question is specifically about using the Asp.net State Service in a custom session state tool – Dan Drews Mar 18 '16 at 12:52