Right. How do you determine the difference between: 1. User attemtped to access a secure page while not logged in.And... 2.
User was logged in, then login expired, and user was redirected to login page.
Forms authentication will automatically append a URL parameter 'ReturnURL', indicating what page (if any) triggered the redirection to the login page. Most websites have a 'Default. Aspx' or 'index.
Html' etc as the default page. You can check the ReturnURL to see if it contains the default page, or some other page in your application. EXAMPLE: string refererURL; if (page.Request.
QueryString"ReturnURL"! = null) { refererURL = page.Request. QueryString"ReturnURL".ToString(); } //Check to see if user was redirected because of Timeout or initial login //Where "Default.
Aspx" is the default page for your application if (refererURL! = "" && refererURL! = (ResolveUrl("~") + "Default.
Aspx")) { //Show HTML etc showing session timeout message } else // User redirected here to to initial login { //Show HTML showing initial login HTML message etc }.
Good idea. This may work great for my current app, but for others I've done, there have been links on anonymous pages to pages that require authentication, and so the returnurl isn't enough to tell the difference between a timeout or first attempt at a protected age. But, I think this should work in many cases, and combining it with looking at the actual value of returnurl should make it even better.
Thanks for the reply. – RyanW Aug 30 '09 at 21:12.
When you have forms authentication setup to redirect to login. Aspx when accessing a protected page, what's a good way to detect in login. Aspx whether the user was sent there because they haven't logged on yet, or because their forms auth ticket is expired?
I'd like to display a "you've timed out" message. I've solved this in the past by having another cooke "hasloggedin" set when a user logs in and then checks to see if that exists to determine if it's a timeout and then display an appropriate message. But, this has to be a common problem?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.