469,890 Members | 1,541 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

How to check if enableSessionState is on w/o triggerring exception

This one should be simple, but I can't find the answer in MSDN.

There are cases when it's necessary for controls, master pages and other
reusable units of code-behind to determine at run time whether Session state
support is enabled. Simply checking if(this.Session != null) is not working -
producing HttpException.

I would like to find a less expensive, exception-free way to check whether
session state support is turned on for the current page (I know I can read
web.config, but I am interested in checking individual page's setting, and
not whole app's).

Thank you,

--
Vlad Hrybok
http://UltiDev.com
Nov 12 '08 #1
2 3878
use:

if (this.Context.Session != null)
-- bruce (sqlwork.com)

Vlad Hrybok wrote:
This one should be simple, but I can't find the answer in MSDN.

There are cases when it's necessary for controls, master pages and other
reusable units of code-behind to determine at run time whether Session state
support is enabled. Simply checking if(this.Session != null) is not working -
producing HttpException.

I would like to find a less expensive, exception-free way to check whether
session state support is turned on for the current page (I know I can read
web.config, but I am interested in checking individual page's setting, and
not whole app's).

Thank you,
Nov 12 '08 #2
It worked, thank you, Bruce.
--
Vlad Hrybok
"bruce barker" wrote:
use:

if (this.Context.Session != null)
-- bruce (sqlwork.com)

Vlad Hrybok wrote:
This one should be simple, but I can't find the answer in MSDN.

There are cases when it's necessary for controls, master pages and other
reusable units of code-behind to determine at run time whether Session state
support is enabled. Simply checking if(this.Session != null) is not working -
producing HttpException.

I would like to find a less expensive, exception-free way to check whether
session state support is turned on for the current page (I know I can read
web.config, but I am interested in checking individual page's setting, and
not whole app's).

Thank you,
Nov 12 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by StepH | last post: by
6 posts views Thread by benben | last post: by
1 post views Thread by stuart | last post: by
2 posts views Thread by André Nogueira | last post: by
41 posts views Thread by Zytan | last post: by
11 posts views Thread by greg | last post: by
3 posts views Thread by Miro | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.