Turn on / off session state for each controller / action method

We are creating an ASP.NET MVC application that will be deployed behind a hardware load balancer that supports, among other things, caching.

Our suggestion is to manually determine which URL patterns should be cached by the load balancer. This will be a fairly simple process for us, because we have “catalog” pages that are relatively static, and then “ordered” pages that are not.

Avoid using session state on cached pages, as the entire response is cached by the load balancer - this includes any cookies sent.

Ideally, there should be an attribute that can be applied to controllers or action methods that allow you to selectively use session state, but don't seem to exist. I understand that this approach will lead to lost sessions, if the use leaves a "session zone" - that's fine.

Besides re-implementing the entire ASP.NET MVC HTTP controller ... any suggestions?

Thanks in advance.

+17
caching asp.net-mvc session-state zeus
Feb 12 '10 at 10:00
source share
2 answers
+4
Feb 12 2018-10-12
source share

Now it is moving from futures to MVC3. There, the attribute ControllerSessionState (apparently, will have the name SessionState for the final version of MVC3), which can be applied to the controller, something like this:

 [SessionState(SessionStateBehavior.Disabled)] public class MyController : Controller { ... 

(But in RC version you have to use ControllerSessionState

+48
Nov 20 2018-10-21T00:
source share



All Articles