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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?VmxhZCBIcnlib2s=?=

    #1

    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

  • bruce barker

    #2
    Re: How to check if enableSessionSt ate is on w/o triggerring exception

    use:

    if (this.Context.S ession != 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,
    >

    Comment

    • =?Utf-8?B?VmxhZCBIcnlib2s=?=

      #3
      Re: How to check if enableSessionSt ate is on w/o triggerring excep

      It worked, thank you, Bruce.
      --
      Vlad Hrybok


      "bruce barker" wrote:
      use:
      >
      if (this.Context.S ession != 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,
      >

      Comment

      Working...