开发者

How to enable session on just a page level not on all the website?

I am developing a website to extend community server, and i found that community server disabled the session in the web.co开发者_开发技巧nfig <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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜