Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > What to do with Authentication/Session Timeout?

Reply
Thread Tools

What to do with Authentication/Session Timeout?

 
 
Simon Says
Guest
Posts: n/a
 
      11-18-2006
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


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      11-18-2006
"Simon Says" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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...?


 
Reply With Quote
 
 
 
 
Simon Says
Guest
Posts: n/a
 
      11-18-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Simon Says" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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...?
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      11-18-2006
"Simon Says" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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);
}
}
}



 
Reply With Quote
 
Simon Says
Guest
Posts: n/a
 
      11-18-2006
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" <(E-Mail Removed)> wrote in message
news:Op59$(E-Mail Removed)...
> "Simon Says" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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);
> }
> }
> }
>
>
>



 
Reply With Quote
 
Mat
Guest
Posts: n/a
 
      11-18-2006
why dont you increase the timeout in web.config?

"Simon Says" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      11-18-2006
"Simon Says" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> 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...


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      11-18-2006
"Mat" <(E-Mail Removed)> wrote in message
newsoD7h.75254$(E-Mail Removed)...

> 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...?


 
Reply With Quote
 
Simon Says
Guest
Posts: n/a
 
      11-18-2006
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" <(E-Mail Removed)> wrote in message
newsoD7h.75254$(E-Mail Removed)...
> why dont you increase the timeout in web.config?
>
> "Simon Says" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Olaf Rabbachin
Guest
Posts: n/a
 
      11-18-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments