Question

I am developing a website to extend community server, and i found that community server disabled the session in the web.config <sessionState mode="Off" />.
Now i have a webpage that i created and must use session inside it, but i don't want to edit the web.config sessionState value,
Can i enable session state on just the page level? or there is another idea to do that?

Was it helpful?

Solution

I don't know that you can enable session state just for a single page - possible, but unlikely.

Instead, you could look to use either the ASP.NET Cache, which is similar but does not isolate data between sessions (you'd have to do that yourself). Or, you could look to create a static data structure somewhere in your application that manages per-session state. Lastly, you may be able to just make your objects serializable and store them in ViewState (if they aren't to large). ViewState can be configured at the individual page (or even Control) level.

You should try to be consistent with the approach your organization has chosen regarding state management. There may be a reason that server-side state is being avoided (perhaps for something like load balancing). Without understanding the reasoning behind this decision, you may introduce unexpected problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top