When session is invalid, how to redirect user to the login page

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

    When session is invalid, how to redirect user to the login page

    I have a asp.net app. When session is invalid, how to redirect user to the
    login page? I don't want to add the code to redirect user to the login page
    into every page.

    Thanks,
    -Billy
  • bruce barker

    #2
    Re: When session is invalid, how to redirect user to the login page

    this is what the global.asax is for. PostAcquireRequ estState would be a
    good event.

    -- bruce (sqlwork.com)

    Billy Zhang wrote:
    I have a asp.net app. When session is invalid, how to redirect user to the
    login page? I don't want to add the code to redirect user to the login page
    into every page.
    >
    Thanks,
    -Billy

    Comment

    • Steven Cheng

      #3
      RE: When session is invalid, how to redirect user to the login page

      Hi Billy,

      Are you using custom forms authentication which is based on some
      information stored in session? Anyway, if you do need a central place
      where you can check session state and redirect request, you can consider
      the approach Bruce introduced(use some global events ).

      And instead of using global.asax, you can also write a custom httpmodule to
      hook any of the global events in ASP.NET. Here are two kb articles
      introduce this:

      #INFO: ASP.NET HTTP Modules and HTTP Handlers Overview


      #How To Create an ASP.NET HTTP Module Using Visual C# .NET


      Hope this helps.

      Sincerely,

      Steven Cheng

      Microsoft MSDN Online Support Lead


      Delighting our customers is our #1 priority. We welcome your comments and
      suggestions about how we

      can improve the support we provide to you. Please feel free to let my
      manager know what you think of

      the level of service provided. You can send feedback directly to my manager
      at: msdnmg@microsof t.com.

      =============== =============== =============== =====
      Get notification to my posts through email? Please refer to

      http://msdn.microsoft.com/en-us/subs...#notifications.

      --------------------
      >From: =?Utf-8?B?QmlsbHkgWmh hbmc=?= <htinns@noemail .noemail>
      >Subject: When session is invalid, how to redirect user to the login page
      >Date: Mon, 10 Nov 2008 19:04:00 -0800
      >I have a asp.net app. When session is invalid, how to redirect user to
      the
      >login page? I don't want to add the code to redirect user to the login
      page
      >into every page.
      >
      >Thanks,
      >-Billy
      >

      Comment

      • jacerhea

        #4
        Re: When session is invalid, how to redirect user to the login page

        You may also consider using a base page. Basically, create a class
        that inherits from System.Web.UI.P age and have all of your aspx pages
        inherit from that class. You can than put your session check code in
        there.



        Comment

        Working...