Checking Session value

Discussion in 'ASP .Net' started by tofu.captain, Dec 8, 2006.

  1. tofu.captain

    tofu.captain Guest

    I have a bunch of administrative ASPX pages that requires me to check
    for a Session value. I have a Masterpage.master file that all these
    ASPX pages use, that checks this. The problem is that the codebehind
    for each of those ASPX pages runs before the codebehind in the
    Masterpage file.

    I run my check in the Masterpage as:
    protected void Page_Load(object sender, EventArgs e)
    {
    if (Session["foo"] != null)
    // Load page
    else
    Response.Redirect("Login.aspx");
    }

    Each of those ASPX pages uses the Session value. Is my only option to
    put the Session check in each of the ASPX pages instead of the
    Masterpage file?
     
    tofu.captain, Dec 8, 2006
    #1
    1. Advertising

  2. tofu.captain

    bruce barker Guest

    you could just use the builtin authentication code in asp.net. turn on
    web authentication, set the admin pages as requiring authentication and
    you're done.

    -- bruce (sqlwork.com)

    tofu.captain wrote:
    > I have a bunch of administrative ASPX pages that requires me to check
    > for a Session value. I have a Masterpage.master file that all these
    > ASPX pages use, that checks this. The problem is that the codebehind
    > for each of those ASPX pages runs before the codebehind in the
    > Masterpage file.
    >
    > I run my check in the Masterpage as:
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (Session["foo"] != null)
    > // Load page
    > else
    > Response.Redirect("Login.aspx");
    > }
    >
    > Each of those ASPX pages uses the Session value. Is my only option to
    > put the Session check in each of the ASPX pages instead of the
    > Masterpage file?
    >
     
    bruce barker, Dec 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Smythe
    Replies:
    3
    Views:
    1,291
    Jeff Smythe
    Jan 2, 2004
  2. -
    Replies:
    0
    Views:
    329
  3. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,351
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  4. ocean
    Replies:
    2
    Views:
    444
    ocean
    Oct 18, 2005
  5. Jazzis
    Replies:
    2
    Views:
    266
    Jazzis
    Sep 23, 2003
Loading...

Share This Page