Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problems with Session.IsNewSession - please help

Reply
Thread Tools

Problems with Session.IsNewSession - please help

 
 
rsouza
Guest
Posts: n/a
 
      12-14-2006
Hi.

Recently here in my work we added the following code in the Global.asax
file to handled the session expired and redirect users to the home of
the site explaining them the occurred (some thing like "Your session
has expired, please restart your navigation.").

public void Session_Start(Object sender, EventArgs e) {

if(Session.IsNewSession && Request.Headers["Cookie"] != null &&
Request.Headers["Cookie"].IndexOf("ASP.NET_SessionId") >= 0)
{
Response.Redirect("/index.aspx?timeout=1");
// when the param "timeout" exists in the url the user
receives the message "... Session expired ..."
}
}

In our tests the code above works fine, but now sometimes we open the
browser, type the url address of the site and the message "... session
expired ..." appears. This occurs just in some machines and not all the
times we access the site.

Someone knows what is happening??

Thanks

Rodrigo

 
Reply With Quote
 
 
 
 
Peter Bradley
Guest
Posts: n/a
 
      12-14-2006
This is completely off the top of my head, so I may be way out.

Firstly, I'm not sure that this is best way of achieving what you seem to be
after. What we do is to check for session timeouts in the page load event
on each page of our applications (using Session.IsNewSession()). If it's a
new session, we set a flag (either in a custom object, or in the Session)
and redirect the user to the login page, which checks for the existence of
the flag.

Looking at your code, you need to check each element in your if statement to
see why all of them are true.

It appears to me that Session.IsNewSession will always be true in the
Session_Start event handler. If the Session wasn't new, it presumably
wouldn't be starting. So your problem, if you must use the Session_Start
event, really is in knowing why the other two conditions are true.

But as I said, this is right off the top of my head.


Peter

"rsouza" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi.
>
> Recently here in my work we added the following code in the Global.asax
> file to handled the session expired and redirect users to the home of
> the site explaining them the occurred (some thing like "Your session
> has expired, please restart your navigation.").
>
> public void Session_Start(Object sender, EventArgs e) {
>
> if(Session.IsNewSession && Request.Headers["Cookie"] != null &&
> Request.Headers["Cookie"].IndexOf("ASP.NET_SessionId") >= 0)
> {
> Response.Redirect("/index.aspx?timeout=1");
> // when the param "timeout" exists in the url the user
> receives the message "... Session expired ..."
> }
> }
>
> In our tests the code above works fine, but now sometimes we open the
> browser, type the url address of the site and the message "... session
> expired ..." appears. This occurs just in some machines and not all the
> times we access the site.
>
> Someone knows what is happening??
>
> Thanks
>
> Rodrigo
>



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      12-14-2006
"rsouza" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...

> Someone knows what is happening??


Get rid of the check for the cookie - it's not necessary.


 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments