Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3667754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:02:25+00:00 2026-05-19T02:02:25+00:00

i am new in asp.net form authentication and sessions i would like to know

  • 0

i am new in asp.net form authentication and sessions

i would like to know how to save session in masterpage or in global.asax
and how to clear session

how to better handle session timeout by redirecting to a page

this is my web.config session settings

<sessionState mode="InProc" cookieless="false" timeout="1"></sessionState>

code in my masterpage

 if (Request.Url.AbsolutePath.EndsWith("SessionExpired.aspx", StringComparison.InvariantCultureIgnoreCase))
    {
        HtmlMeta meta = new HtmlMeta();
        meta.HttpEquiv = "Refresh";
        meta.Content = "7; URL=./Login.aspx";
        Page.Header.Controls.Add(meta);
    }
    else
        HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60)) + "; Url=./Public/SessionExpired.aspx");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:02:26+00:00Added an answer on May 19, 2026 at 2:02 am

    As such, your strategy looks OK to me but I would have preferred a different implementation:

    1. Use an abstract class derived from System.Web.UI.Page as a base class for all pages. Let’s say we call this class as a BasePage.
    2. Add a virtual method such as IsRefreshHeaderNeeded – the default implementation will return true. The method will be invoked in PreRender stage of BasePage to add actual refresh header in response.
    3. In SessionExpired page, IsRefreshHeaderNeeded will be overridden to return false. (Similar can be needed in pages such as login or pages that don’t need session support).
    4. Refresh header/meta to redirect to login page will be added in SessionExpired page itself (really its a logic within the page, why to put it at global place). SessionExpired page would of course have link for use to manually navigate to login page (in case redirect does not work).

    Master page is a content template and I prefer to have only logic related that that content within the master page.

    Yet another strategy is not to use client side refresh for session expiry but rather do it from server side when you dictates that current session has expired when user visits the site back. Extending further, you may even have implementation that save critical session data into database so that you can reconstruct the session and from user experience perspective, there will be no session expiry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new In ASP.NET, I want to create to Login Form using Membership
I am new to ASP.NET MVC, particularly ajax operations. I have a form with
When I add a new form to an ASP.NET project (WebForms), and then View
I created a new ASP.NET MVC application. The home page looks like this: I
I have a question about using form authentication in ASP.net MVC. I ran aspnet_regsql
I am creating a web application using Form Authentication of Asp.Net with C# and
I am using form authentication inmy ASP.NET 2.0 website. Today during testing i was
I can not make it clear about how the asp.net's authentication work,I set the
I have a website with ASP.NET Forms Authentication. I recently implement to save cookie
New ASP.NET Web API HttpClient has been giving me some strange results. Here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.