Does the SessionState attribute match in MVC 3?

I manage a fairly large project written in asp.net webforms + mvc3, with a large user base and a fairly high daily number of visitors. Basically, there are many requests at any given time.

One of my controllers in MVC, which processes / resizes images on the fly, has the following attribute to it:

[SessionState(SessionStateBehavior.Disabled)] 

Now, if an action in the controller tries to access the session - it obviously throws an exception - so we are still good.

The problem is this: if I go to the IIS workflow window (Win Server 2008 R2, IIS 7.5) and check the current requests to this site, sometimes I can see action requests in this controller. Their current state is locked in State: RequestAcquireState, Module Name: Session . Sometimes these locks pass in a second or two in this state.

Wasn’t the whole point of the attribute primarily that requests to the controller ignore the state, and do not waste time (and, possibly, are blocked), trying to get the state?

If so - am I doing something wrong here, or is the problem somewhere else?

+7
source share
1 answer

[moved from comments]

If you are using a custom factory controller or route handler, make sure they are aware of the controller session state. Marking the controller as not requiring a session state requires collaboration from both of these components. Out of the box, DefaultControllerFactory and MvcRouteHandler are designed to work with this. See DefaultControllerFactory.GetControllerSessionBehavior and MvcRouteHandler.GetHttpHandler for more information. If you write custom components, you can use these methods as inspiration.

+12
source

All Articles