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 6019919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:29:29+00:00 2026-05-23T03:29:29+00:00

In my asp.net web application, I’m using asp.net forms authentication with following configuration. <authentication

  • 0

In my asp.net web application, I’m using asp.net forms authentication with following configuration.

<authentication mode="Forms">
    <forms name=".ASPNETAUTH" loginUrl="Login.aspx" protection="None" timeout="20" />
</authentication>

After form authentication time out, I would like to redirect to a different page. For example to ‘SessionTimedOut.aspx’ page.

I’ve found other questions on here, here is one, Forms Authentication Timeout vs Session Timeout

The answer given makes sense but the first line of code has me confused.

var cookie = Retrieve AuthenticationCookie();

if (cookie == null) return;

FormsAuthenticationTicket ticket = null;

try {
    ticket = FormsAuthentication.Decrypt(cookie.Value);
} catch (Exceptoin decryptError) {
    // Handle properly
}

if (ticket == null) return; // Not authorised

if (ticket.Expiration > DateTime.Now) {
    Response.Redirect("SessionExpiredPage.aspx"); // Or do other stuff here
}

Now there is a

FormsAuthentication.GetAuthCookie()

which takes a username and bool to persist the cookie, but this is for creating an auth cookie not getting it. So, what would the var cookie, first line of code look like.

At the moment, I am using ” in web config and then when user logins in settings a session and then on every post back in a page init in my base page am checking if that session is null, if so, redirecting to a session timed out page. This is not really what I want.

May have found out how to get cookie,

HttpCookie cookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);

This doesn’t work because when the authentication ticket expires, the cookie goes away and the the cookie var is null. Any other way to get this working? I would still like on post back check if authentication has expired and then take appropriate action. Any thoughts from anyone????

  • 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-23T03:29:30+00:00Added an answer on May 23, 2026 at 3:29 am

    The thing to remember is that even though your session times out on the server end, the client end will not process anything until it’s next request. At that time it will discover that it’s session has expired and attempt to restart the session. A Response.Redirect or even Server.Redirect call won’t help with this.

    What you need to do is to synchronize your server timeout with your client timeout, and have some client script in place to redirect the user to a “Timed Out” type page. I’ve written up an article with some sample code on how to do that here.

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

Sidebar

Related Questions

I have an ASP.NET web application which does the following: Reads an Excel file.
I have an ASP.NET web application and I'm thinking about the following: before sending
I'm writing an asp.net Web Application. I wrote a login page that authenticates a
In my ASP .NET web application, when I first navigate to the login page,
I have a asp.net web application using MVC framework, the website allows the registrars
I will create an ASP.NET Web Application like this; Users can login their own
I need my ASP.NET web application to use silverlight controls in my web page.
When I build my ASP.NET web application I get a .dll file with the
Consider a standard ASP.NET web application where the user types in some numeric data
I'm building an ASP.NET web application, and all of my strings are stored in

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.