473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

What to do with Authentication/Session Timeout?

Hi,

I've a login page in which after authenticating it via the Oracle DB, I will
stored the user information into the Session. However, when the Session
timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying "...
Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.

Thanks,
Simon
Nov 18 '06 #1
20 3740
"Simon Says" <si******@gmail.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
I've a login page in which after authenticating it via the Oracle DB, I
will stored the user information into the Session. However, when the
Session timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying "...
Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.
Have you tried Server.Transfer instead of Response.Redirect...?
Nov 18 '06 #2
Yes. Tried that and am still getting the same error message.

I've alot of client side javascripting in my code. I placed my Redirect call
in the Page_Load event in the .vb code. When the javascript code triggered
the Redirect, I'll have the error. But, when I execute a server control
event, like a clicking a button that do a postback, my Redirect works fine.

--Simon
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:eg**************@TK2MSFTNGP02.phx.gbl...
"Simon Says" <si******@gmail.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
>I've a login page in which after authenticating it via the Oracle DB, I
will stored the user information into the Session. However, when the
Session timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying
"... Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.

Have you tried Server.Transfer instead of Response.Redirect...?

Nov 18 '06 #3
"Simon Says" <si******@gmail.comwrote in message
news:eS**************@TK2MSFTNGP04.phx.gbl...
I've alot of client side javascripting in my code.
OK.
I placed my Redirect call in the Page_Load event in the .vb code.
Ah - that might explain it...Does your page have other Page events (e.g.
Page_Init, Page_Prerender, Page_Unload etc)...

I've encountered similar issues with Response.Redirect - e.g. if you place
Response.Redirect in your Page_Init method, the Page_Load method will still
fire, but if you use Server.Transfer, the transfer will happen
immediately...
When the javascript code triggered the Redirect, I'll have the error.
??? What do you mean exactly - how is your client-side JavaScript making a
call to Response.Redirect...?

Generally speaking, I do all of this stuff in a base class which all pages
inherit, or which the MasterPage(s) inherit(s):

public class BaseMasterEvents : Page
{
public BaseMasterEvents()
{
this.PreInit += new EventHandler(BaseMaster_PreInit);
}

private void BaseMaster_PreInit(object sender, EventArgs e)
{
if (Session.IsNewSession)
{
Server.Transfer("~/sessionTimedOut.htm", false);
}
}
}

Nov 18 '06 #4
Yes. My page does has Page_init, and Page_Load events.

I'm working with some controls with AJAX functionality. Basically the tree
node click, in AJAX, will invoke a grid event in the server side to query
from DB, and display out the results ... all without having the page to
refresh. But, the page events still follows as if it's a postback action.So
.... when I do a tree node click, it will
1. Page_init
2. Page_load
3. grid_InitializeDataSource (this query the DB)
4. Page_init
5. Page_load

I've placed my session checking in the Page_Init event, and tried both
Redirect and Server.Transfer; and both giving me the same exception. I've
also tried your suggestion and do it in my master page PreInit event, and
I'm also getting the same exception.

I got desparate and tried ClientScript.RegisterStartUpScript to do a
"window.location.replace(login.aspx)" and it too doesn't do anything.

--Simon
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:Op**************@TK2MSFTNGP06.phx.gbl...
"Simon Says" <si******@gmail.comwrote in message
news:eS**************@TK2MSFTNGP04.phx.gbl...
>I've alot of client side javascripting in my code.

OK.
>I placed my Redirect call in the Page_Load event in the .vb code.

Ah - that might explain it...Does your page have other Page events (e.g.
Page_Init, Page_Prerender, Page_Unload etc)...

I've encountered similar issues with Response.Redirect - e.g. if you place
Response.Redirect in your Page_Init method, the Page_Load method will
still fire, but if you use Server.Transfer, the transfer will happen
immediately...
>When the javascript code triggered the Redirect, I'll have the error.

??? What do you mean exactly - how is your client-side JavaScript making a
call to Response.Redirect...?

Generally speaking, I do all of this stuff in a base class which all pages
inherit, or which the MasterPage(s) inherit(s):

public class BaseMasterEvents : Page
{
public BaseMasterEvents()
{
this.PreInit += new EventHandler(BaseMaster_PreInit);
}

private void BaseMaster_PreInit(object sender, EventArgs e)
{
if (Session.IsNewSession)
{
Server.Transfer("~/sessionTimedOut.htm", false);
}
}
}

Nov 18 '06 #5
Mat
why dont you increase the timeout in web.config?

"Simon Says" <si******@gmail.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
Hi,

I've a login page in which after authenticating it via the Oracle DB, I
will stored the user information into the Session. However, when the
Session timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying "...
Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.

Thanks,
Simon

Nov 18 '06 #6
"Simon Says" <si******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Yes. My page does has Page_init, and Page_Load events.
Ah...
I'm working with some controls with AJAX functionality. Basically the tree
node click, in AJAX, will invoke a grid event in the server side to query
from DB, and display out the results ... all without having the page to
refresh. But, the page events still follows as if it's a postback
action.So ... when I do a tree node click, it will
1. Page_init
2. Page_load
3. grid_InitializeDataSource (this query the DB)
4. Page_init
5. Page_load
You appear to be loading the page twice - why do steps 4 and 5 occur?
I've placed my session checking in the Page_Init event, and tried both
Redirect and Server.Transfer; and both giving me the same exception. I've
also tried your suggestion and do it in my master page PreInit event, and
I'm also getting the same exception.
Hmm - MasterPages don't have a PreInit event, so I'm assuming you're doing
the same Page inheritance stuff as I am...

I'm starting to run out of ideas now...
Nov 18 '06 #7
"Mat" <Ma*******@hotmail.comwrote in message
news:xo********************@weber.videotron.net...
why dont you increase the timeout in web.config?
ROTFLMAO!!!

When you get a warning light in your car, do you just do the Homer Simpson
fix by putting a strip of tape over it...?
Nov 18 '06 #8
Well ... coz my boss disagree to it :-)

I'm using a longer timeout for a temp. fix now, but ... the site just feels
more professional if it can re-direct whenever the timeout occurs.

"Mat" <Ma*******@hotmail.comwrote in message
news:xo********************@weber.videotron.net...
why dont you increase the timeout in web.config?

"Simon Says" <si******@gmail.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
>Hi,

I've a login page in which after authenticating it via the Oracle DB, I
will stored the user information into the Session. However, when the
Session timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying
"... Redirect not all in Page Callback".

Could anyone give me some pointer how I should approach this issue.

Thanks,
Simon


Nov 18 '06 #9
Hi,

Simon Says wrote:
I've a login page in which after authenticating it via the Oracle DB, I will
stored the user information into the Session. However, when the Session
timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying "...
Redirect not all in Page Callback".
maybe I misunderstand something, but have you tried something like:

If Session("User") Is Nothing then
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()
Return
End If

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 18 '06 #10
I think step 4 and 5 occurs coz the initializeDataSource event. In step 3, I
got the dataset and stored it in the Cache, then in Step5, I assigned the
dataset from the Cache and blind it to my grid.

Ya ... I've the PreInit in the child page; not in the master page.

Man ... this web development thinggy is not as easy as I though. Thanks for
all your ideas though.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
"Simon Says" <si******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Yes. My page does has Page_init, and Page_Load events.

Ah...
>I'm working with some controls with AJAX functionality. Basically the
tree node click, in AJAX, will invoke a grid event in the server side to
query from DB, and display out the results ... all without having the
page to refresh. But, the page events still follows as if it's a postback
action.So ... when I do a tree node click, it will
1. Page_init
2. Page_load
3. grid_InitializeDataSource (this query the DB)
4. Page_init
5. Page_load

You appear to be loading the page twice - why do steps 4 and 5 occur?
>I've placed my session checking in the Page_Init event, and tried both
Redirect and Server.Transfer; and both giving me the same exception. I've
also tried your suggestion and do it in my master page PreInit event, and
I'm also getting the same exception.

Hmm - MasterPages don't have a PreInit event, so I'm assuming you're doing
the same Page inheritance stuff as I am...

I'm starting to run out of ideas now...

Nov 18 '06 #11
"Simon Says" <si******@gmail.comwrote in message
news:OR**************@TK2MSFTNGP02.phx.gbl...
>I think step 4 and 5 occurs coz the initializeDataSource event.
Nope - something is causing your page to load twice...
In step 3, I got the dataset and stored it in the Cache, then in Step5, I
assigned the dataset from the Cache and blind it to my grid.
That's surely not right...you must be loading the page twice...

Why do you need to store the dataset in Cache?
Nov 18 '06 #12
re:
Man ... this web development thinggy is not as easy as I though.
I have to chuckle a bit at that. We *all* went through that phase.

Don't let it faze you.

A correct assessment of the difficulties involved in learning
anything is often the first step towards mastering a subject.

The worst thing anybody could do is underestimate a challenge.

Take things one day at a time.
Solve today's problem's today, and let tomorrow's problems be solved tomorrow.

Carry on. You'll do fine with your kind of attitude.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Simon Says" <si******@gmail.comwrote in message news:OR**************@TK2MSFTNGP02.phx.gbl...
>I think step 4 and 5 occurs coz the initializeDataSource event. In step 3, I got the dataset and
stored it in the Cache, then in Step5, I assigned the dataset from the Cache and blind it to my
grid.

Ya ... I've the PreInit in the child page; not in the master page.

Man ... this web development thinggy is not as easy as I though. Thanks for all your ideas though.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message news:uR**************@TK2MSFTNGP04.phx.gbl...
>"Simon Says" <si******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Yes. My page does has Page_init, and Page_Load events.

Ah...
>>I'm working with some controls with AJAX functionality. Basically the tree node click, in AJAX,
will invoke a grid event in the server side to query from DB, and display out the results ...
all without having the page to refresh. But, the page events still follows as if it's a postback
action.So ... when I do a tree node click, it will
1. Page_init
2. Page_load
3. grid_InitializeDataSource (this query the DB)
4. Page_init
5. Page_load

You appear to be loading the page twice - why do steps 4 and 5 occur?
>>I've placed my session checking in the Page_Init event, and tried both Redirect and
Server.Transfer; and both giving me the same exception. I've also tried your suggestion and do
it in my master page PreInit event, and I'm also getting the same exception.

Hmm - MasterPages don't have a PreInit event, so I'm assuming you're doing the same Page
inheritance stuff as I am...

I'm starting to run out of ideas now...


Nov 18 '06 #13
Well ... even if it load twice ... in the 1st Load or Init, my Redirect or
Server.Transfer should work; but they are giving me the same Callback
exception. Right?

Sorry ... I use the Session to store my dataset, not the Cache. The reason
I'm storing it is because if the dataset already exist, I'll not requery the
DB again.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:eV**************@TK2MSFTNGP04.phx.gbl...
"Simon Says" <si******@gmail.comwrote in message
news:OR**************@TK2MSFTNGP02.phx.gbl...
>>I think step 4 and 5 occurs coz the initializeDataSource event.

Nope - something is causing your page to load twice...
>In step 3, I got the dataset and stored it in the Cache, then in Step5, I
assigned the dataset from the Cache and blind it to my grid.

That's surely not right...you must be loading the page twice...

Why do you need to store the dataset in Cache?

Nov 18 '06 #14
Yes. I've tried that too, and it also gives me the same Callback exception.
I tried, in my web.config, to have the following statement ...

<authentication mode="Forms">
<forms loginUrl="login.aspx" timeout="10" />
</authentication>

When timeout occurs, the page still doesn't redirect itself to the login
page. However, I tried adding in a button that does nothing, and when time
out occurs, clicking on the button will triggers a postback in which it will
redirect to the login page. This is the closest I got, but it doesn't solve
my problem because in my website, in most cases, the session will timeout
when user does a AJAX/javascript/client-side action (like a tree node
click).
"Olaf Rabbachin" <Ol*********@IntuiDev.comwrote in message
news:ev**************@TK2MSFTNGP03.phx.gbl...
Hi,

Simon Says wrote:
>I've a login page in which after authenticating it via the Oracle DB, I
will
stored the user information into the Session. However, when the Session
timeout occurs, all of the user information will be lost.

I've tried doing a Reponse.Redirect call back to my login page whenever I
detected the Session is null, but I kept getting the exception saying
"...
Redirect not all in Page Callback".

maybe I misunderstand something, but have you tried something like:

If Session("User") Is Nothing then
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage()
Return
End If

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com

Nov 18 '06 #15
"Simon Says" <si******@gmail.comwrote in message
news:ei**************@TK2MSFTNGP04.phx.gbl...
Well ... even if it load twice ... in the 1st Load or Init, my Redirect or
Server.Transfer should work; but they are giving me the same Callback
exception. Right?
Without knowing why it's failing, it's impossible to say... However, there
really should be no need for the page to be loading twice - that should
certainly be addressed...
Sorry ... I use the Session to store my dataset, not the Cache.
Aha - think we might be getting somewhere now...

You're persisting a dataset in Session, which is fine for data which
(almost) never changes, but your app is failing when the Session times out.

Could it possibly be that your page is trying to reference the dataset held
in Session BEFORE it determines that the Session has timed out...?
Nov 18 '06 #16
Thanks for the encourgement Juan. It's just that working on the weekend
makes me a little cranky :-)

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:O1**************@TK2MSFTNGP02.phx.gbl...
re:
>Man ... this web development thinggy is not as easy as I though.

I have to chuckle a bit at that. We *all* went through that phase.

Don't let it faze you.

A correct assessment of the difficulties involved in learning
anything is often the first step towards mastering a subject.

The worst thing anybody could do is underestimate a challenge.

Take things one day at a time.
Solve today's problem's today, and let tomorrow's problems be solved
tomorrow.

Carry on. You'll do fine with your kind of attitude.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Simon Says" <si******@gmail.comwrote in message
news:OR**************@TK2MSFTNGP02.phx.gbl...
>>I think step 4 and 5 occurs coz the initializeDataSource event. In step 3,
I got the dataset and stored it in the Cache, then in Step5, I assigned
the dataset from the Cache and blind it to my grid.

Ya ... I've the PreInit in the child page; not in the master page.

Man ... this web development thinggy is not as easy as I though. Thanks
for all your ideas though.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>>"Simon Says" <si******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .

Yes. My page does has Page_init, and Page_Load events.

Ah...

I'm working with some controls with AJAX functionality. Basically the
tree node click, in AJAX, will invoke a grid event in the server side
to query from DB, and display out the results ... all without having
the page to refresh. But, the page events still follows as if it's a
postback action.So ... when I do a tree node click, it will
1. Page_init
2. Page_load
3. grid_InitializeDataSource (this query the DB)
4. Page_init
5. Page_load

You appear to be loading the page twice - why do steps 4 and 5 occur?

I've placed my session checking in the Page_Init event, and tried both
Redirect and Server.Transfer; and both giving me the same exception.
I've also tried your suggestion and do it in my master page PreInit
event, and I'm also getting the same exception.

Hmm - MasterPages don't have a PreInit event, so I'm assuming you're
doing the same Page inheritance stuff as I am...

I'm starting to run out of ideas now...



Nov 18 '06 #17
Nope ... I have my checking in the very 1st line, therefore, if there's a
session timeout, it will never reach to the line where it's referencing the
dataset in the Session.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
"Simon Says" <si******@gmail.comwrote in message
news:ei**************@TK2MSFTNGP04.phx.gbl...
>Well ... even if it load twice ... in the 1st Load or Init, my Redirect
or Server.Transfer should work; but they are giving me the same Callback
exception. Right?

Without knowing why it's failing, it's impossible to say... However, there
really should be no need for the page to be loading twice - that should
certainly be addressed...
>Sorry ... I use the Session to store my dataset, not the Cache.

Aha - think we might be getting somewhere now...

You're persisting a dataset in Session, which is fine for data which
(almost) never changes, but your app is failing when the Session times
out.

Could it possibly be that your page is trying to reference the dataset
held in Session BEFORE it determines that the Session has timed out...?

Nov 18 '06 #18
Hi,

Juan T. Llibre wrote:
>Man ... this web development thinggy is not as easy as I though.

I have to chuckle a bit at that. We *all* went through that phase.
[...]
Carry on. You'll do fine with your kind of attitude.
thanks from me as well - guess Simon and me are in the same boat (and no
shore in sight yet :-) ... But hey, apart from all the hassle I'm still
having lots of fun with it, and learning something new every day isn't bad
either.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 18 '06 #19
Hi,

Simon Says wrote:
Yes. I've tried that too, and it also gives me the same Callback exception.
I tried, in my web.config, to have the following statement ...

<authentication mode="Forms">
<forms loginUrl="login.aspx" timeout="10" />
</authentication>

When timeout occurs, the page still doesn't redirect itself to the login
page. However, I tried adding in a button that does nothing, and when time
out occurs, clicking on the button will triggers a postback in which it will
redirect to the login page. This is the closest I got, but it doesn't solve
my problem because in my website, in most cases, the session will timeout
when user does a AJAX/javascript/client-side action (like a tree node
click).
hmm. I haven't ever (which isn't all that long anyway) used a
timeout-attribute within the authentication-tag. In my web.config, I'm
setting the timeout within my sessionState-tag, as in:
<sessionState mode="InProc" timeout="20"/>
As an alternative, you might also set the timeout for your application
within your website's IIS-settings. But I guess that won't make any
difference ...

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 18 '06 #20
"Simon Says" <si******@gmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Nope ... I have my checking in the very 1st line, therefore, if there's a
session timeout, it will never reach to the line where it's referencing
the dataset in the Session.
Hmm - OK, then - can you please post the entire code for the page in
question...
Nov 18 '06 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark MacRae | last post by:
I am trying to do some testing of my application with respect to timeouts (i.e. Session timeouts). I took the advice of somebody else in this newsgroup (I think) and set my forms authentication...
4
by: Jay | last post by:
I have authentication set for my site but I need one page to be an exception case. Namely my forgot password page. How do I tell the webconfig file to authenciate all pages except one page? ...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
2
by: Dotnet Guy | last post by:
Hi, I have different asp.net applications as sub applications within an application and was using Framework 1.0. And I use forms authentication across the applications. In the web.config file of...
1
by: Andy Fish | last post by:
Hi, I have an asp.net web app whereby I authenticate the user with Forms Authentication and store details about him in the session. I want to be able to catch an event when the users...
1
by: Ben S | last post by:
we have a webapp using form authentication, and the time out is set at 120 minutes, so whenever a session is idle for > 120 minutes or so, it will make the user sign in again. This seems to be...
15
by: Edwin Knoppert | last post by:
I have searched but info is limitted. In my test app i used a non persistant cookie for forms authentication. slidingExpiration is set to true On run and close and rerun the login remains ok....
7
by: Adrian Parker | last post by:
We have an application that's running ok on most of our customers machines, but on one of them we get an error. They're running on windows 2003 server with iis6. In the web.config, the...
1
by: gnewsgroup | last post by:
I am using forms authentication for a web application. Like many other member web application, my web application prints out Welcome! John Doe (Logout) on the top right corner of each...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.