Click here to Skip to main content
15,889,266 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionLogin Control Woes Pin
Richard Blythe15-Dec-09 11:17
Richard Blythe15-Dec-09 11:17 
AnswerRe: Login Control Woes Pin
Adam °Wimsatt15-Dec-09 11:46
Adam °Wimsatt15-Dec-09 11:46 
GeneralRe: Login Control Woes Pin
Richard Blythe15-Dec-09 11:51
Richard Blythe15-Dec-09 11:51 
GeneralRe: Login Control Woes Pin
Adam °Wimsatt15-Dec-09 12:30
Adam °Wimsatt15-Dec-09 12:30 
GeneralRe: Login Control Woes Pin
Richard Blythe15-Dec-09 13:11
Richard Blythe15-Dec-09 13:11 
QuestionRegular expression for the time format 'HHMMAMPM' Pin
chandra vempati15-Dec-09 10:01
chandra vempati15-Dec-09 10:01 
QuestionTime Out Issue.....Javascript inside of an ASP.net application Pin
PDTUM15-Dec-09 9:10
PDTUM15-Dec-09 9:10 
AnswerRe: Time Out Issue.....Javascript inside of an ASP.net application Pin
Abhishek Sur15-Dec-09 9:32
professionalAbhishek Sur15-Dec-09 9:32 
Good thinking...

The way we all do in your scenario is we put a variable in session,and try to call the Variable. Say:
Session.Add("IsAuthenticated", true)

Now for every call to the server we validate this using
if(Session["IsAuthenticated"])

If Session cant be retrieved, we will see if the current request url is Login page. If not we pass it to Login using

login.aspx?RetUrl=yourcurrentpage.aspx

Thus if the user successfully logs in again, it will be redirected to original page.
And regarding Session Timeout exception, we just ignore it using try/catch.

This is our way of doing this, as we handle all of them in Server.

Well, if you like to handle this is client, It is better to keep a variable variable in Javascript which will hold the time when the last call is made. You might use this javascript in OnLoad event of Body.

var responsetime = new Date();

Now whenever any call to the server is made, you just use
var thisTime = new Date();
var difftime= new Date();
difftime.setTime(thisTime.getTime() - responsetime.getTime());
if(difftime.getMinutes() > 20){
  alert('Session Expired');
  location.href='login.aspx';
  return false;
}
else
  return true;


I hope this would seem to be a better approach to you.

Cheers.
Rose | [Rose]

Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->

Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript

QuestionAbout asp.net system slowdown Pin
leone15-Dec-09 6:06
leone15-Dec-09 6:06 
AnswerRe: About asp.net system slowdown Pin
Abhijit Jana15-Dec-09 6:22
professionalAbhijit Jana15-Dec-09 6:22 
AnswerRe: About asp.net system slowdown Pin
Abhishek Sur15-Dec-09 7:17
professionalAbhishek Sur15-Dec-09 7:17 
QuestionQuestion about writing a conditional SQL statement Pin
James Shao15-Dec-09 4:28
James Shao15-Dec-09 4:28 
AnswerRe: Question about writing a conditional SQL statement [modified] Pin
dan!sh 15-Dec-09 5:00
professional dan!sh 15-Dec-09 5:00 
GeneralRe: Question about writing a conditional SQL statement Pin
James Shao15-Dec-09 12:43
James Shao15-Dec-09 12:43 
GeneralRe: Question about writing a conditional SQL statement Pin
James Shao15-Dec-09 15:50
James Shao15-Dec-09 15:50 
GeneralRe: Question about writing a conditional SQL statement Pin
dan!sh 15-Dec-09 17:06
professional dan!sh 15-Dec-09 17:06 
QuestionXPATH problem Pin
Rohit16db15-Dec-09 3:22
Rohit16db15-Dec-09 3:22 
AnswerRe: XPATH problem Pin
Abhishek Sur15-Dec-09 10:30
professionalAbhishek Sur15-Dec-09 10:30 
QuestionPage updating Pin
#realJSOP15-Dec-09 0:59
mve#realJSOP15-Dec-09 0:59 
AnswerRe: Page updating Pin
Eduard Keilholz15-Dec-09 1:08
Eduard Keilholz15-Dec-09 1:08 
GeneralRe: Page updating Pin
#realJSOP15-Dec-09 3:14
mve#realJSOP15-Dec-09 3:14 
AnswerRe: Page updating Pin
dan!sh 15-Dec-09 1:27
professional dan!sh 15-Dec-09 1:27 
GeneralRe: Page updating Pin
#realJSOP15-Dec-09 3:10
mve#realJSOP15-Dec-09 3:10 
GeneralRe: Page updating Pin
dan!sh 15-Dec-09 3:28
professional dan!sh 15-Dec-09 3:28 
GeneralRe: Page updating Pin
#realJSOP15-Dec-09 3:42
mve#realJSOP15-Dec-09 3:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.