Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Saturday, March 31, 2012

Session time-out,when the page breaks?

Hi..

I had published a website in the server( I am using VS 2005,ASP.NET2.0, With C#) . I tried testing the site by asking several users to login to the website and do unit testing. At one instance of time, the page breaks for a particular user. When the page breaks, the other users who are tesing in their machine are getting a session time-out and are forced to log out.

Why is such a session-time out issue happening, when one of the users page breaks. I have set the session variable to 20 minutes,which is the default. But what's confusing is , when one of the user's page breaks, the others get a session time-out? Why is such a session-time out occuring?

Please help.

Thanks.

What do you mean when you say "the page breaks?" If an app pool cycles you might see this effect. Have you diagnosed the "page break" to see what happens?

Jeff


Thank you very much for the reply.

The page break, I referred is the page crashing(asp.net error page) .I have customized the error page to show, An Unexpected error occurred, please try after some time.

But when the user tries the same steps to find the page crash, he is not able to, as the page works well. This is a kind of absurd. The page is not crashing always, but it is random. I checked the log, but it was not providing much information. I also could not re-trace the page crash, as the page worked well.

But why is the session getting timed out for the other users, when one of the users page crashes?

Thanks.


Hi..

I am sorry that I forgot to include a scenario in my web page,which i am doing. I have written a code to delete a folder in the session end in global.asax. When i commented the code, and tried testing, the session time out was not occuring.

I searched in the google, and came out with this:

http://www.velocityreviews.com/forums/t116975-all-session-are-getting-down-when-i-delete-sessions-folders.html

Is this the reason for all sessions getting timed-out, when a page crashes?

Thanks


Hi Venkatzeus,

As far as i know, if you delete a folder which is in your application directory, the appDomain will restart, and you will lose your session.

I hope this helps.


This happens as your worker process memory limits get full and asp.net worker process gets restarted. how to do this setting you can find at

http://www.asp.net/faq/AspNetAndIIS6.aspx

But I think you needs to findout why its getting full.

When you get this error check server CPU Usage what it shows?

then debug.


HI,,

Thank you very much for the reply. I will try with it and provide the results.

Thanks

Session Timeout..

When the session times out, I would like to navigate to the login page.
Currently when the session times out, the displayed screen remains visible
on the screen however when the user clicks on the screen will take to the
login page.

How to do that?

BenjaminYou could try using the javascript setTimeout function set to 20 minutes
(the default session timeout period) and then set the
document.location.href='login.aspx' via client side code.
Here's an example of using the javascript setTimeout function:
http://www.crowes.f9.co.uk/Javascript/timer.htm

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
news:%23%23YjkXrmEHA.3608@.TK2MSFTNGP09.phx.gbl...
> When the session times out, I would like to navigate to the login page.
> Currently when the session times out, the displayed screen remains visible
> on the screen however when the user clicks on the screen will take to the
> login page.
> How to do that?
> Benjamin
Hi i had the same problem.
Buti fixed..
If u need a more detailed script let me know!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Yes, I need to know.
Benjamin

"naijacoder naijacoder" <naijacoder@.toughguy.net> wrote in message
news:eu0aGPsmEHA.3988@.tk2msftngp13.phx.gbl...
> Hi i had the same problem.
> Buti fixed..
> If u need a more detailed script let me know!
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
But what do you really want to do?

"Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
news:eFTtrasmEHA.2908@.TK2MSFTNGP12.phx.gbl...
> Yes, I need to know.
> Benjamin
> "naijacoder naijacoder" <naijacoder@.toughguy.net> wrote in message
> news:eu0aGPsmEHA.3988@.tk2msftngp13.phx.gbl...
> > Hi i had the same problem.
> > Buti fixed..
> > If u need a more detailed script let me know!
> > *** Sent via Developersdex http://www.developersdex.com ***
> > Don't just participate in USENET...get rewarded for it!
Steve gave you the answer. In more detail:

Session times out (by default) 20 minutes after the last Request was
received by the client browser instance holding that SessionID in a
temporary cookie. As no request is received on the server, no response can
be sent to the client. Therefore, the redirect MUST occur on the client.
That means JavaScript. And that means that your JavaScript function should
fire just as the Session times out (20 minutes). You would use the
JavaScript setTimeOut() function to accomplish this.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
news:eFTtrasmEHA.2908@.TK2MSFTNGP12.phx.gbl...
> Yes, I need to know.
> Benjamin
> "naijacoder naijacoder" <naijacoder@.toughguy.net> wrote in message
> news:eu0aGPsmEHA.3988@.tk2msftngp13.phx.gbl...
> > Hi i had the same problem.
> > Buti fixed..
> > If u need a more detailed script let me know!
> > *** Sent via Developersdex http://www.developersdex.com ***
> > Don't just participate in USENET...get rewarded for it!
Thanks for your answers.

Now I understand I have to use setTimeout to achieve my goal.

The link http://www.crowes.f9.co.uk/Javascript/timer.htm is really helpful.

Which client side event I should use to keep track the user is still using
the website.

Thanks,

Benjamin

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:#lv4LermEHA.324@.TK2MSFTNGP11.phx.gbl...
> You could try using the javascript setTimeout function set to 20 minutes
> (the default session timeout period) and then set the
> document.location.href='login.aspx' via client side code.
> Here's an example of using the javascript setTimeout function:
> http://www.crowes.f9.co.uk/Javascript/timer.htm
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
> news:%23%23YjkXrmEHA.3608@.TK2MSFTNGP09.phx.gbl...
> > When the session times out, I would like to navigate to the login page.
> > Currently when the session times out, the displayed screen remains
visible
> > on the screen however when the user clicks on the screen will take to
the
> > login page.
> > How to do that?
> > Benjamin
Also I would like to inform the user just before X seconds of page expiry. I
do not want to use alert(). Is it possible to display the message on the
tool bar as once the count down for expire starts.

Thanks,

Benjamin

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:#lv4LermEHA.324@.TK2MSFTNGP11.phx.gbl...
> You could try using the javascript setTimeout function set to 20 minutes
> (the default session timeout period) and then set the
> document.location.href='login.aspx' via client side code.
> Here's an example of using the javascript setTimeout function:
> http://www.crowes.f9.co.uk/Javascript/timer.htm
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
> news:%23%23YjkXrmEHA.3608@.TK2MSFTNGP09.phx.gbl...
> > When the session times out, I would like to navigate to the login page.
> > Currently when the session times out, the displayed screen remains
visible
> > on the screen however when the user clicks on the screen will take to
the
> > login page.
> > How to do that?
> > Benjamin
The browser will keep track of that for you.
All you need is one client side event to fire once the trigger time has
elapsed and you want to warn the user.
You can name the event anything you want.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Benjamin" <BenSmithNg@.hotmail.com> wrote in message
news:uan1PfQnEHA.392@.tk2msftngp13.phx.gbl...
> Thanks for your answers.
> Now I understand I have to use setTimeout to achieve my goal.
> The link http://www.crowes.f9.co.uk/Javascript/timer.htm is really
> helpful.
> Which client side event I should use to keep track the user is still using
> the website.
> Thanks,
> Benjamin
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:#lv4LermEHA.324@.TK2MSFTNGP11.phx.gbl...
>> You could try using the javascript setTimeout function set to 20 minutes
>> (the default session timeout period) and then set the
>> document.location.href='login.aspx' via client side code.
>> Here's an example of using the javascript setTimeout function:
>> http://www.crowes.f9.co.uk/Javascript/timer.htm
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://Steve.Orr.net
>>
>>
>> "Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
>> news:%23%23YjkXrmEHA.3608@.TK2MSFTNGP09.phx.gbl...
>> > When the session times out, I would like to navigate to the login page.
>> > Currently when the session times out, the displayed screen remains
> visible
>> > on the screen however when the user clicks on the screen will take to
> the
>> > login page.
>>> > How to do that?
>>> > Benjamin
>>>>
>>
Yes you can display a message to the status bar of the browser.
Here's a nice example:
http://simplythebest.net/scripts/DH...ascript_58.html

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Benjamin" <BenSmithNg@.hotmail.com> wrote in message
news:uGdHQhQnEHA.3520@.TK2MSFTNGP11.phx.gbl...
> Also I would like to inform the user just before X seconds of page expiry.
> I
> do not want to use alert(). Is it possible to display the message on the
> tool bar as once the count down for expire starts.
> Thanks,
> Benjamin
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:#lv4LermEHA.324@.TK2MSFTNGP11.phx.gbl...
>> You could try using the javascript setTimeout function set to 20 minutes
>> (the default session timeout period) and then set the
>> document.location.href='login.aspx' via client side code.
>> Here's an example of using the javascript setTimeout function:
>> http://www.crowes.f9.co.uk/Javascript/timer.htm
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://Steve.Orr.net
>>
>>
>> "Benjamin Smith" <BenSmithNg@.hotmail.com> wrote in message
>> news:%23%23YjkXrmEHA.3608@.TK2MSFTNGP09.phx.gbl...
>> > When the session times out, I would like to navigate to the login page.
>> > Currently when the session times out, the displayed screen remains
> visible
>> > on the screen however when the user clicks on the screen will take to
> the
>> > login page.
>>> > How to do that?
>>> > Benjamin
>>>>
>>

Session Timeout.

Friends,
We have a simple application which has login page, users login to it
and enter their contact details and all other stuff. It is working
fine. Now we have moved to new windows 2003 server. The page works
but it gets refreshed every 5 mintues and goes back to login.aspx page.
How do I fix this.
Thanks for any help.
KAdd this in your Web.config file to elongate Session to 60min for example:
<sessionState cookieless="UseCookies" mode="InProc" timeout="60" />
but add it between
<system.web> </system.web>
--
Bishoy George
bishoy@.bishoy.com
20102550399
"Sai" <kumar877@.gmail.com> wrote in message
news:1145074352.770881.44720@.u72g2000cwu.googlegroups.com...
> Friends,
> We have a simple application which has login page, users login to it
> and enter their contact details and all other stuff. It is working
> fine. Now we have moved to new windows 2003 server. The page works
> but it gets refreshed every 5 mintues and goes back to login.aspx page.
> How do I fix this.
> Thanks for any help.
> K
>
no that did not help. same thing is happening again.
Do you have code in your page to redirect to your login page? Sounds like
your session is timing out and your code is kicking in to repost. Write some
code in your session_end event handler to dump a file with a time-stamp to
tell you when the session is dying. You can trouble-shoot from there.
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
----
"Sai" <kumar877@.gmail.com> wrote in message
news:1145116360.101576.258960@.i40g2000cwc.googlegroups.com...
> no that did not help. same thing is happening again.
>
Hi Alvin,
thanks for the advise. Iam inputting the values to a text file when
session times out. It is coming as 60 seconds. So the session is
timing out at every 60 seconds, but I could not find where to change
these value. I checked the web.config and machine.config and
application pools .
Let me know specific place to change this value.
thanks,
K
So you have an override somewhere in your code because the timeout value is
20 minutes by default. Search your code for that value. Alternatively, it
may be overridden in the web.config file. As a quick test, you can set
session.timeout = 10 minutes. It should stick otherwise, you have something
funky going on in your app that you either don't know about or aren't
sharing.
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
----
"Sai" <kumar877@.gmail.com> wrote in message
news:1145288352.456543.4650@.t31g2000cwb.googlegroups.com...
> Hi Alvin,
> thanks for the advise. Iam inputting the values to a text file when
> session times out. It is coming as 60 seconds. So the session is
> timing out at every 60 seconds, but I could not find where to change
> these value. I checked the web.config and machine.config and
> application pools .
> Let me know specific place to change this value.
> thanks,
> K
>
Nothing in the code, nothing in the web.config. It has to be some
other place. I have seen all my code and no where I am setting these
values.
I tried changing session timeout to 10 minutes and still nothing
happens. So it got to be some where, not that simple.
Where else it can be.?
Thanks.
K
you need that check. go back and put it in there so that your application
can be resilient to memory issues. However, raise the limit to around 1gig
or so. The reason for this is that the application pool should be recycled
if an errant application (your code) decides to hog memory. Removing that
check prevents detection of this and other conditions.
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
----
"Sai" <kumar877@.gmail.com> wrote in message
news:1145306983.181641.177810@.i40g2000cwc.googlegroups.com...
> Thanks for all your help. It got fixed just now. The problem is
> Virtual memory was so low (250MB), so every time a worker process
> initiates it goes to 250 MB and it recycles, so what we did was, we
> just removed the check box next to virtual memory of application pool.
> that's it. It works...great relief.
> Thanks,
> K
>
Thanks for all your help. It got fixed just now. The problem is
Virtual memory was so low (250MB), so every time a worker process
initiates it goes to 250 MB and it recycles, so what we did was, we
just removed the check box next to virtual memory of application pool.
that's it. It works...great relief.
Thanks,
K
Where is the Virtual memory checked/set? Somewhere in IIS?
Ron

Session Timeout.

Friends,

We have a simple application which has login page, users login to it
and enter their contact details and all other stuff. It is working
fine. Now we have moved to new windows 2003 server. The page works
but it gets refreshed every 5 mintues and goes back to login.aspx page.
How do I fix this.

Thanks for any help.

KAdd this in your Web.config file to elongate Session to 60min for example:

<sessionState cookieless="UseCookies" mode="InProc" timeout="60" /
but add it between
<system.web> </system.web>
--

Bishoy George
bishoy@.bishoy.com
20102550399

--------

"Sai" <kumar877@.gmail.com> wrote in message
news:1145074352.770881.44720@.u72g2000cwu.googlegro ups.com...
> Friends,
> We have a simple application which has login page, users login to it
> and enter their contact details and all other stuff. It is working
> fine. Now we have moved to new windows 2003 server. The page works
> but it gets refreshed every 5 mintues and goes back to login.aspx page.
> How do I fix this.
> Thanks for any help.
> K
no that did not help. same thing is happening again.
Do you have code in your page to redirect to your login page? Sounds like
your session is timing out and your code is kicking in to repost. Write some
code in your session_end event handler to dump a file with a time-stamp to
tell you when the session is dying. You can trouble-shoot from there.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-----------------

"Sai" <kumar877@.gmail.com> wrote in message
news:1145116360.101576.258960@.i40g2000cwc.googlegr oups.com...
> no that did not help. same thing is happening again.
Hi Alvin,

thanks for the advise. Iam inputting the values to a text file when
session times out. It is coming as 60 seconds. So the session is
timing out at every 60 seconds, but I could not find where to change
these value. I checked the web.config and machine.config and
application pools .

Let me know specific place to change this value.

thanks,
K
So you have an override somewhere in your code because the timeout value is
20 minutes by default. Search your code for that value. Alternatively, it
may be overridden in the web.config file. As a quick test, you can set
session.timeout = 10 minutes. It should stick otherwise, you have something
funky going on in your app that you either don't know about or aren't
sharing.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-----------------

"Sai" <kumar877@.gmail.com> wrote in message
news:1145288352.456543.4650@.t31g2000cwb.googlegrou ps.com...
> Hi Alvin,
> thanks for the advise. Iam inputting the values to a text file when
> session times out. It is coming as 60 seconds. So the session is
> timing out at every 60 seconds, but I could not find where to change
> these value. I checked the web.config and machine.config and
> application pools .
> Let me know specific place to change this value.
> thanks,
> K
Nothing in the code, nothing in the web.config. It has to be some
other place. I have seen all my code and no where I am setting these
values.
I tried changing session timeout to 10 minutes and still nothing
happens. So it got to be some where, not that simple.
Where else it can be.?

Thanks.
K
Thanks for all your help. It got fixed just now. The problem is
Virtual memory was so low (250MB), so every time a worker process
initiates it goes to 250 MB and it recycles, so what we did was, we
just removed the check box next to virtual memory of application pool.
that's it. It works...great relief.

Thanks,
K
you need that check. go back and put it in there so that your application
can be resilient to memory issues. However, raise the limit to around 1gig
or so. The reason for this is that the application pool should be recycled
if an errant application (your code) decides to hog memory. Removing that
check prevents detection of this and other conditions.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-----------------

"Sai" <kumar877@.gmail.com> wrote in message
news:1145306983.181641.177810@.i40g2000cwc.googlegr oups.com...
> Thanks for all your help. It got fixed just now. The problem is
> Virtual memory was so low (250MB), so every time a worker process
> initiates it goes to 250 MB and it recycles, so what we did was, we
> just removed the check box next to virtual memory of application pool.
> that's it. It works...great relief.
> Thanks,
> K
Where is the Virtual memory checked/set? Somewhere in IIS?

Ron
it's under one of the application pool health monitoring tabs in IIS

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-----------------

"RonL" <sal_paradise_93@.yahoo.com> wrote in message
news:1145322157.561147.218050@.j33g2000cwa.googlegr oups.com...
> Where is the Virtual memory checked/set? Somewhere in IIS?
> Ron
I couldn't find it. I see you're talking about Windows 2003 and I'm
looking at IIS 5 and XP Pro on my local machine.

Ron
IIS 5 doesn't have these characteristics. sorry.

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Professional VSTO.NET - Wrox/Wiley 2006
-----------------

"RonL" <sal_paradise_93@.yahoo.com> wrote in message
news:1145411388.245339.46900@.i40g2000cwc.googlegro ups.com...
>I couldn't find it. I see you're talking about Windows 2003 and I'm
> looking at IIS 5 and XP Pro on my local machine.
> Ron

Session Timeout..

Also I would like to inform the user just before X seconds of page expiry. I
do not want to use alert(). Is it possible to display the message on the
tool bar as once the count down for expire starts.
Thanks,
Benjamin
"Steve C. Orr [MVP, MCSD]" <Steve@dotnet.itags.org.Orr.net> wrote in message
news:#lv4LermEHA.324@dotnet.itags.org.TK2MSFTNGP11.phx.gbl...
> You could try using the javascript setTimeout function set to 20 minutes
> (the default session timeout period) and then set the
> document.location.href='login.aspx' via client side code.
> Here's an example of using the javascript setTimeout function:
> http://www.crowes.f9.co.uk/Javascript/timer.htm
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
> "Benjamin Smith" <BenSmithNg@dotnet.itags.org.hotmail.com> wrote in message
> news:%23%23YjkXrmEHA.3608@dotnet.itags.org.TK2MSFTNGP09.phx.gbl...
visible
the
>Yes you can display a message to the status bar of the browser.
Here's a nice example:
http://simplythebest.net/scripts/DH...//Steve.Orr.net
"Benjamin" <BenSmithNg@.hotmail.com> wrote in message
news:uGdHQhQnEHA.3520@.TK2MSFTNGP11.phx.gbl...
> Also I would like to inform the user just before X seconds of page expiry.
> I
> do not want to use alert(). Is it possible to display the message on the
> tool bar as once the count down for expire starts.
> Thanks,
> Benjamin
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:#lv4LermEHA.324@.TK2MSFTNGP11.phx.gbl...
> visible
> the
>

Session Times Out.... Navigate to Login Page

When the sessions times out I would like to take the user to the login page.
Currently even though session times out user will come to know only when he
clicks on the screen. How to direct the user automatically to login page
once the session times out. I am using .Net Framework 1.1. and IIS 5
AmithYou could force the browser to refresh after a set amount of time:
Response.AppendHeader("Refresh", (Session.Timeout * 60 +
10).ToString() + "; URL=Login.aspx");
This will calculate the time to refresh using the Session timeout
value on the server (specified in minutes).
HTH,
Scott
http://www.OdeToCode.com
On Sat, 4 Sep 2004 11:14:52 -0700, "Amith Singh"
<AmithSin@.hotmail.com> wrote:

>When the sessions times out I would like to take the user to the login page
.
>Currently even though session times out user will come to know only when he
>clicks on the screen. How to direct the user automatically to login page
>once the session times out. I am using .Net Framework 1.1. and IIS 5
>Amith
>
Amith Singh wrote:

> When the sessions times out I would like to take the user to the login pag
e.
> Currently even though session times out user will come to know only when h
e
> clicks on the screen. How to direct the user automatically to login page
> once the session times out. I am using .Net Framework 1.1. and IIS 5
> Amith
>
Run a cli9ent sided time somwhere somehow and when I reaches the 20
minutes (default session timeout setting) you do something like a popup,
redirect, etc.
//Rutger
DoDotNet@.Gmail.com
www.RutgerSmit.com
Rutger Smit wrote:

> Amith Singh wrote:
>
> Run a cli9ent sided time somwhere somehow and when I reaches the 20
> minutes (default session timeout setting) you do something like a popup,
> redirect, etc.
>
Where was my mind?
Here the intended answer:
Run a clientsided script somewhere somehow and when it reaches the 20
minutes (default session timeout setting) you do something like a popup,
redirect, etc.
//Rutger
DoDotNet@.Gmail.com
www.RutgerSmit.com
I tried doing something like this before. I added some client side code on
page load to redirect after 20 minutes or whatever. Problem was a user
could stay on the same page for more than 20 minutes and keep the session
alive by posting back to itself. But when the client side script hit 20
minutes from the initial page load... whoops... times up.
I would like to see a solution myself.
Greg
"Rutger Smit" <DoDotNet@.gmail.com> wrote in message
news:10jk7k75fscpdbb@.corp.supernews.com...
> Rutger Smit wrote:
>
> Where was my mind?
> Here the intended answer:
>
> Run a clientsided script somewhere somehow and when it reaches the 20
> minutes (default session timeout setting) you do something like a popup,
> redirect, etc.
> --
> //Rutger
> DoDotNet@.Gmail.com
> www.RutgerSmit.com
Greg Burns wrote:

> I tried doing something like this before. I added some client side code o
n
> page load to redirect after 20 minutes or whatever. Problem was a user
> could stay on the same page for more than 20 minutes and keep the session
> alive by posting back to itself. But when the client side script hit 20
> minutes from the initial page load... whoops... times up.
> I would like to see a solution myself.
> Greg
>
>
>
Maybe you can make the script a little bit more intelligent.
On the client: do the time thing that redirects after 20 minutes.
Redirect the client to a special page that check wheter the session is
still alive or not. If it is, no broblem, redirect the client to the
HTTP_REFERER header value. If the session has expired, redir to login page.
//Rutger
DoDotNet@.Gmail.com
www.RutgerSmit.com
I would think if I redirected using HTTP_REFERER header value that it would
cause IsPostBack to False again, plus viewstate would not be retained. I
would be as if it was the first time visiting the page.
Here is some code I was playing with that I found while visiting the online
ticket ordering at sixflags.com.
function WarnUserTimeout()
{
alert('Your session has expired. You are being redirected to the park
selection page.')
window.location.href = "tickets_parkselect.asp";
}
<body OnLoad="window. setTimeout('WarnUserTimeout()',10*60*100
0)">
What would be great is if there was someway to reset the timer on every post
back...
Greg

> Maybe you can make the script a little bit more intelligent.
> On the client: do the time thing that redirects after 20 minutes.
> Redirect the client to a special page that check wheter the session is
> still alive or not. If it is, no broblem, redirect the client to the
> HTTP_REFERER header value. If the session has expired, redir to login
page.
> --
> //Rutger
> DoDotNet@.Gmail.com
> www.RutgerSmit.com
Greg Burns wrote:
> I would think if I redirected using HTTP_REFERER header value that it woul
d
> cause IsPostBack to False again, plus viewstate would not be retained. I
> would be as if it was the first time visiting the page.
> Here is some code I was playing with that I found while visiting the onlin
e
> ticket ordering at sixflags.com.
> function WarnUserTimeout()
> {
> alert('Your session has expired. You are being redirected to the park
> selection page.')
> window.location.href = "tickets_parkselect.asp";
> }
> <body OnLoad="window. setTimeout('WarnUserTimeout()',10*60*100
0)">
> What would be great is if there was someway to reset the timer on every po
st
> back...
> Greg
>
>
'reset the timer on every post back'
It does since it's JavaScript and thus running client sided.
If you're using frames you have to do some cross frame scripting with a
function that sets the timer to zero.
//Rutger
DoDotNet@.Gmail.com
www.RutgerSmit.com
You know, you're right.
I just retested it to make sure I wasn't making this up, but couldn't
duplicate it. I definately had a problem with this very issue when I first
attempted this. I will need to take a second look.
Thanks,
Greg

> 'reset the timer on every post back'
> It does since it's JavaScript and thus running client sided.
> If you're using frames you have to do some cross frame scripting with a
> function that sets the timer to zero.
> --
> //Rutger
> DoDotNet@.Gmail.com
> www.RutgerSmit.com

Session Times Out.... Navigate to Login Page

When the sessions times out I would like to take the user to the login page.
Currently even though session times out user will come to know only when he
clicks on the screen. How to direct the user automatically to login page
once the session times out. I am using .Net Framework 1.1. and IIS 5
AmithYou could force the browser to refresh after a set amount of time:

Response.AppendHeader("Refresh", (Session.Timeout * 60 +
10).ToString() + "; URL=Login.aspx");

This will calculate the time to refresh using the Session timeout
value on the server (specified in minutes).

HTH,

--
Scott
http://www.OdeToCode.com

On Sat, 4 Sep 2004 11:14:52 -0700, "Amith Singh"
<AmithSin@.hotmail.com> wrote:

>When the sessions times out I would like to take the user to the login page.
>Currently even though session times out user will come to know only when he
>clicks on the screen. How to direct the user automatically to login page
>once the session times out. I am using .Net Framework 1.1. and IIS 5
>Amith
Amith Singh wrote:

> When the sessions times out I would like to take the user to the login page.
> Currently even though session times out user will come to know only when he
> clicks on the screen. How to direct the user automatically to login page
> once the session times out. I am using .Net Framework 1.1. and IIS 5
> Amith

Run a cli9ent sided time somwhere somehow and when I reaches the 20
minutes (default session timeout setting) you do something like a popup,
redirect, etc.

--

//Rutger

DoDotNet@.Gmail.com
www.RutgerSmit.com
Rutger Smit wrote:

> Amith Singh wrote:
>
> Run a cli9ent sided time somwhere somehow and when I reaches the 20
> minutes (default session timeout setting) you do something like a popup,
> redirect, etc.

Where was my mind?
Here the intended answer:

Run a clientsided script somewhere somehow and when it reaches the 20
minutes (default session timeout setting) you do something like a popup,
redirect, etc.

--

//Rutger

DoDotNet@.Gmail.com
www.RutgerSmit.com
I tried doing something like this before. I added some client side code on
page load to redirect after 20 minutes or whatever. Problem was a user
could stay on the same page for more than 20 minutes and keep the session
alive by posting back to itself. But when the client side script hit 20
minutes from the initial page load... whoops... times up.

I would like to see a solution myself.

Greg

"Rutger Smit" <DoDotNet@.gmail.com> wrote in message
news:10jk7k75fscpdbb@.corp.supernews.com...
> Rutger Smit wrote:
> > Amith Singh wrote:
> > Run a cli9ent sided time somwhere somehow and when I reaches the 20
> > minutes (default session timeout setting) you do something like a popup,
> > redirect, etc.
> Where was my mind?
> Here the intended answer:
>
> Run a clientsided script somewhere somehow and when it reaches the 20
> minutes (default session timeout setting) you do something like a popup,
> redirect, etc.
> --
> //Rutger
> DoDotNet@.Gmail.com
> www.RutgerSmit.com
Greg Burns wrote:

> I tried doing something like this before. I added some client side code on
> page load to redirect after 20 minutes or whatever. Problem was a user
> could stay on the same page for more than 20 minutes and keep the session
> alive by posting back to itself. But when the client side script hit 20
> minutes from the initial page load... whoops... times up.
> I would like to see a solution myself.
> Greg
>>Where was my mind?
>>Here the intended answer:
>>
>>
>>Run a clientsided script somewhere somehow and when it reaches the 20
>>minutes (default session timeout setting) you do something like a popup,
>> redirect, etc.
>>
>>--
>>
>>//Rutger
>>
>>DoDotNet@.Gmail.com
>>www.RutgerSmit.com

Maybe you can make the script a little bit more intelligent.
On the client: do the time thing that redirects after 20 minutes.
Redirect the client to a special page that check wheter the session is
still alive or not. If it is, no broblem, redirect the client to the
HTTP_REFERER header value. If the session has expired, redir to login page.

--

//Rutger

DoDotNet@.Gmail.com
www.RutgerSmit.com
I would think if I redirected using HTTP_REFERER header value that it would
cause IsPostBack to False again, plus viewstate would not be retained. I
would be as if it was the first time visiting the page.

Here is some code I was playing with that I found while visiting the online
ticket ordering at sixflags.com.

function WarnUserTimeout()
{
alert('Your session has expired. You are being redirected to the park
selection page.')
window.location.href = "tickets_parkselect.asp";
}

<body OnLoad="window.setTimeout('WarnUserTimeout()',10*60*1000)"
What would be great is if there was someway to reset the timer on every post
back...

Greg

> Maybe you can make the script a little bit more intelligent.
> On the client: do the time thing that redirects after 20 minutes.
> Redirect the client to a special page that check wheter the session is
> still alive or not. If it is, no broblem, redirect the client to the
> HTTP_REFERER header value. If the session has expired, redir to login
page.
> --
> //Rutger
> DoDotNet@.Gmail.com
> www.RutgerSmit.com
Greg Burns wrote:
> I would think if I redirected using HTTP_REFERER header value that it would
> cause IsPostBack to False again, plus viewstate would not be retained. I
> would be as if it was the first time visiting the page.
> Here is some code I was playing with that I found while visiting the online
> ticket ordering at sixflags.com.
> function WarnUserTimeout()
> {
> alert('Your session has expired. You are being redirected to the park
> selection page.')
> window.location.href = "tickets_parkselect.asp";
> }
> <body OnLoad="window.setTimeout('WarnUserTimeout()',10*60*1000)">
> What would be great is if there was someway to reset the timer on every post
> back...
> Greg

'reset the timer on every post back'
It does since it's JavaScript and thus running client sided.
If you're using frames you have to do some cross frame scripting with a
function that sets the timer to zero.

--

//Rutger

DoDotNet@.Gmail.com
www.RutgerSmit.com
You know, you're right.

I just retested it to make sure I wasn't making this up, but couldn't
duplicate it. I definately had a problem with this very issue when I first
attempted this. I will need to take a second look.

Thanks,
Greg

> 'reset the timer on every post back'
> It does since it's JavaScript and thus running client sided.
> If you're using frames you have to do some cross frame scripting with a
> function that sets the timer to zero.
> --
> //Rutger
> DoDotNet@.Gmail.com
> www.RutgerSmit.com

Session troubble with IE 5 on Mac

I'm having troubble with sessions when accessing my ASP.NET 2.0 BETA 2 webapp using IE 5.2 on a Mac. It seems like everytime I reload a page, I get a new session id. Firefox on the same Mac works fine and keeps it session as long as it should.
I've tested this with a minimal webapp aswell. Just created one single page which prints Session.SessionId. The webapp has a default Web.config.
Is this a known issue?hello.
if i remember correctly, you'll only mantain your session id if you keep any data there. if you don't, you'll get a new id in every request...
The same thing happens if I add data to the session, so i don't think that is the problem. Have any of you successfully managed to use sessions with IE 5 on Mac?
Well, the problem was solved when I installed the final version of ASP.NET 2.0, so it looks like it had something to do with the build I was running.. Weird that nobody else has had this problem.

session uniqueid

Do sessions automatically create a unique ID constraint like a GUID when they are instantiated on a web page? If so how can i retrieve it in C#?

ThanksEach session has a session ID. Use Session.SessionID to get it. This id is, however, not unique all the time.

Session values across subdomains

Is it possible to keep sessions between subdomains?
I.e
If I have a site "shop.com" and when user acess his personal page it's
"secure.shop.com"
Is it possible to share the session values between these two?
Why I ask is because the hosting company gives a discount on SSL
certificates if I put it at secure.shop.com instead of the entire site
and since I only need checkout and personal info pages to be secure I
was thinking that I could put that info in the secure.shop.com domain
but I am worried I will loose session info like cartid, userid and
such..
Regards,
Danielit depends. to share the session cookie, you override the domain in the
session cookie, pretty simple. if secure.shop.com and shop.com are the
same site then you are done. if they are different sites and you use
inproc session, then you will need some way to pass session data from
one site to another (say a web service).
-- bruce (sqlwork.com)
daniel.westerberg@.ruilong.se wrote:
> Is it possible to keep sessions between subdomains?
> I.e
> If I have a site "shop.com" and when user acess his personal page it's
> "secure.shop.com"
> Is it possible to share the session values between these two?
> Why I ask is because the hosting company gives a discount on SSL
> certificates if I put it at secure.shop.com instead of the entire site
> and since I only need checkout and personal info pages to be secure I
> was thinking that I could put that info in the secure.shop.com domain
> but I am worried I will loose session info like cartid, userid and
> such..
> Regards,
> Daniel

Thursday, March 29, 2012

Session values across subdomains

Is it possible to keep sessions between subdomains?
I.e
If I have a site "shop.com" and when user acess his personal page it's
"secure.shop.com"
Is it possible to share the session values between these two?
Why I ask is because the hosting company gives a discount on SSL
certificates if I put it at secure.shop.com instead of the entire site
and since I only need checkout and personal info pages to be secure I
was thinking that I could put that info in the secure.shop.com domain
but I am worried I will loose session info like cartid, userid and
such..

Regards,
Danielit depends. to share the session cookie, you override the domain in the
session cookie, pretty simple. if secure.shop.com and shop.com are the
same site then you are done. if they are different sites and you use
inproc session, then you will need some way to pass session data from
one site to another (say a web service).

-- bruce (sqlwork.com)

daniel.westerberg@.ruilong.se wrote:

Quote:

Originally Posted by

Is it possible to keep sessions between subdomains?
I.e
If I have a site "shop.com" and when user acess his personal page it's
"secure.shop.com"
Is it possible to share the session values between these two?
Why I ask is because the hosting company gives a discount on SSL
certificates if I put it at secure.shop.com instead of the entire site
and since I only need checkout and personal info pages to be secure I
was thinking that I could put that info in the secure.shop.com domain
but I am worried I will loose session info like cartid, userid and
such..
>
Regards,
Daniel

session values

I'm having a problem with sessions. Basically, my site has a place where a
user logs in, and they're taken to a page with the order details and items
from their shopping cart. This order detail page checks a session variable to
check that the customer is logged in. The problem is that some users are
taken back to the login page even though they are entering the correct
username and password. We know that their cookies are on. We have a script on
another page that checks for cookies, and we've scanned through the logs and
it shows that their cookies are on. What is more baffling is that many users
are going through ok, but some are not, and there aren't any patterns as to
their browser type, or isp origin or whatnot. Anyone have a similar issue?Are you using Forms Authentication? If not, you may find that arrangement
more reliable. You can easily set up custom Forms Auth against a database.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"George" wrote:

> I'm having a problem with sessions. Basically, my site has a place where a
> user logs in, and they're taken to a page with the order details and items
> from their shopping cart. This order detail page checks a session variable to
> check that the customer is logged in. The problem is that some users are
> taken back to the login page even though they are entering the correct
> username and password. We know that their cookies are on. We have a script on
> another page that checks for cookies, and we've scanned through the logs and
> it shows that their cookies are on. What is more baffling is that many users
> are going through ok, but some are not, and there aren't any patterns as to
> their browser type, or isp origin or whatnot. Anyone have a similar issue?
>

session values

I'm having a problem with sessions. Basically, my site has a place where a
user logs in, and they're taken to a page with the order details and items
from their shopping cart. This order detail page checks a session variable t
o
check that the customer is logged in. The problem is that some users are
taken back to the login page even though they are entering the correct
username and password. We know that their cookies are on. We have a script o
n
another page that checks for cookies, and we've scanned through the logs and
it shows that their cookies are on. What is more baffling is that many users
are going through ok, but some are not, and there aren't any patterns as to
their browser type, or isp origin or whatnot. Anyone have a similar issue?Are you using Forms Authentication? If not, you may find that arrangement
more reliable. You can easily set up custom Forms Auth against a database.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"George" wrote:

> I'm having a problem with sessions. Basically, my site has a place where a
> user logs in, and they're taken to a page with the order details and items
> from their shopping cart. This order detail page checks a session variable
to
> check that the customer is logged in. The problem is that some users are
> taken back to the login page even though they are entering the correct
> username and password. We know that their cookies are on. We have a script
on
> another page that checks for cookies, and we've scanned through the logs a
nd
> it shows that their cookies are on. What is more baffling is that many use
rs
> are going through ok, but some are not, and there aren't any patterns as t
o
> their browser type, or isp origin or whatnot. Anyone have a similar issue?
>

Session values across subdomains

Is it possible to keep sessions between subdomains?
I.e
If I have a site "shop.com" and when user acess his personal page it's
"secure.shop.com"
Is it possible to share the session values between these two?
Why I ask is because the hosting company gives a discount on SSL
certificates if I put it at secure.shop.com instead of the entire site
and since I only need checkout and personal info pages to be secure I
was thinking that I could put that info in the secure.shop.com domain
but I am worried I will loose session info like cartid, userid and
such..
Regards,
Danielit depends. to share the session cookie, you override the domain in the
session cookie, pretty simple. if secure.shop.com and shop.com are the
same site then you are done. if they are different sites and you use
inproc session, then you will need some way to pass session data from
one site to another (say a web service).
-- bruce (sqlwork.com)
daniel.westerberg@.ruilong.se wrote:
> Is it possible to keep sessions between subdomains?
> I.e
> If I have a site "shop.com" and when user acess his personal page it's
> "secure.shop.com"
> Is it possible to share the session values between these two?
> Why I ask is because the hosting company gives a discount on SSL
> certificates if I put it at secure.shop.com instead of the entire site
> and since I only need checkout and personal info pages to be secure I
> was thinking that I could put that info in the secure.shop.com domain
> but I am worried I will loose session info like cartid, userid and
> such..
> Regards,
> Daniel

session variable

Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

Below is web.config snippet...

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/
Anyone has any clue why its happening like this??

Any help would be appreciated..

Thanx in advance

daveA couple comments. First off, you might save yourself a handful of lines of code as well as this problem if you used the built-in FormsAuthentication:
http://www.15seconds.com/issue/020220.htm
http://www.15seconds.com/issue/020305.htm

I suspect they are getting to index.aspx because the page is cached...hence when they force a refresh they are being logged out. You might want to look at :
http://www.15seconds.com/issue/010202.htm
which will tell you how to make sure the browser doesn't cache the page.

As for why ur session doesn't clear, you might wanna try Response.Redirect("default.aspx", false) If that works check out :
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx for why...not sure if that applies to clearing session though, don't think so.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!)

"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

Below is web.config snippet...

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/
Anyone has any clue why its happening like this??

Any help would be appreciated..

Thanx in advance

dave
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

In C# I would not check for an empty string, but for null. In VB you might need to
check for "Nothing".
You don't store "strings" in Session, you store "objects". A string is a perfectly
valid object, so you can store it without problems. But if the Session variable
has been removed, it's *removed* (not there, nothing), not an empty string.
But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

If you use Redirect, you instruct the browser to go to a different URL, so that other
URL should be displayed (If you had used Transfer, this would not be the case, as that
works entirely server-side). So you are not "redirected" to default.aspx, but something else
happened.

Hans Kesting

Session Variable

Hi

In my ASP.NET project, I have a session variable that is assigned on a login page. In another .cs file (in another directory), I'm trying to use
if((string)Session["variable"] == "something"

When I compile, it tells me that Session does not exist in the calss or namespace

My hypothesis is that it is because this directory is compiled before the directory that actually has the Session variable's declaration. Any ideas on how to fix this

thanks

George"Session" is not a global variable, it is a property of the
System.Web.UI.Page object.
When you use Session["variable"] inside an aspx page, it is actually
translating to this.Session["variable"].
When you are in another class which is not an aspx page derived off of the
Page class, it has no access to the Session object.

You either need to pass a reference to the Session object into your other
class (yuck), or pass the value itself as a parameter/property/etc.

--
Michael J. Mooney
MCP+SB, MCAD, MCSD
"George" <anonymous@.discussions.microsoft.com> wrote in message
news:CE2AB820-0B7C-43E0-BCA6-E3A654E6E18A@.microsoft.com...
> Hi,
> In my ASP.NET project, I have a session variable that is assigned on a
login page. In another .cs file (in another directory), I'm trying to use
> if((string)Session["variable"] == "something")
> When I compile, it tells me that Session does not exist in the calss or
namespace.
> My hypothesis is that it is because this directory is compiled before the
directory that actually has the Session variable's declaration. Any ideas
on how to fix this?
> thanks.
> George
Or you can grab the application object and then access the session:

using System.Web; //Need this at top

HttpApplication ha = HttpContext.Current.ApplicationInstance;

string mySessionValue = ha.Session["MySessionValue"];

Very simple:

VB.NET

Dim ha As HttpApplication = HttpContext.Current.ApplicationInstance
Dim mySessionValue As String = ha.Session("MySessionValue")

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael J. Mooney" <mike_mooney@._yahoo.com.NOSPAM> wrote in message
news:%23tyjDyLTEHA.2336@.TK2MSFTNGP10.phx.gbl...
> "Session" is not a global variable, it is a property of the
> System.Web.UI.Page object.
> When you use Session["variable"] inside an aspx page, it is actually
> translating to this.Session["variable"].
> When you are in another class which is not an aspx page derived off of the
> Page class, it has no access to the Session object.
> You either need to pass a reference to the Session object into your other
> class (yuck), or pass the value itself as a parameter/property/etc.
> --
> Michael J. Mooney
> MCP+SB, MCAD, MCSD
> "George" <anonymous@.discussions.microsoft.com> wrote in message
> news:CE2AB820-0B7C-43E0-BCA6-E3A654E6E18A@.microsoft.com...
> > Hi,
> > In my ASP.NET project, I have a session variable that is assigned on a
> login page. In another .cs file (in another directory), I'm trying to use
> > if((string)Session["variable"] == "something")
> > When I compile, it tells me that Session does not exist in the calss or
> namespace.
> > My hypothesis is that it is because this directory is compiled before
the
> directory that actually has the Session variable's declaration. Any ideas
> on how to fix this?
> > thanks.
> > George

session variable

Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
Below is web.config snippet...
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Anyone has any clue why its happening like this'
Any help would be appreciated..
Thanx in advance
daveA couple comments. First off, you might save yourself a handful of lines of
code as well as this problem if you used the built-in FormsAuthentication:
http://www.15seconds.com/issue/020220.htm
http://www.15seconds.com/issue/020305.htm
I suspect they are getting to index.aspx because the page is cached...hence
when they force a refresh they are being logged out. You might want to look
at :
http://www.15seconds.com/issue/010202.htm
which will tell you how to make sure the browser doesn't cache the page.
As for why ur session doesn't clear, you might wanna try Response.Redirect("
default.aspx", false) If that works check out :
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx for why...not
sure if that applies to clearing session though, don't think so.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!
)
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP
14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
Below is web.config snippet...
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Anyone has any clue why its happening like this'
Any help would be appreciated..
Thanx in advance
dave
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP
14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
In C# I would not check for an empty string, but for null. In VB you might n
eed to
check for "Nothing".
You don't store "strings" in Session, you store "objects". A string is a per
fectly
valid object, so you can store it without problems. But if the Session varia
ble
has been removed, it's *removed* (not there, nothing), not an empty string.
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
If you use Redirect, you instruct the browser to go to a different URL, so t
hat other
URL should be displayed (If you had used Transfer, this would not be the cas
e, as that
works entirely server-side). So you are not "redirected" to default.aspx, bu
t something else
happened.
Hans Kesting

Session Variable

Hi,
In my ASP.NET project, I have a session variable that is assigned on a login
page. In another .cs file (in another directory), I'm trying to use
if((string)Session["variable"] == "something")
When I compile, it tells me that Session does not exist in the calss or name
space.
My hypothesis is that it is because this directory is compiled before the di
rectory that actually has the Session variable's declaration. Any ideas on
how to fix this?
thanks.
George"Session" is not a global variable, it is a property of the
System.Web.UI.Page object.
When you use Session["variable"] inside an aspx page, it is actually
translating to this.Session["variable"].
When you are in another class which is not an aspx page derived off of the
Page class, it has no access to the Session object.
You either need to pass a reference to the Session object into your other
class (yuck), or pass the value itself as a parameter/property/etc.
Michael J. Mooney
MCP+SB, MCAD, MCSD
"George" <anonymous@.discussions.microsoft.com> wrote in message
news:CE2AB820-0B7C-43E0-BCA6-E3A654E6E18A@.microsoft.com...
> Hi,
> In my ASP.NET project, I have a session variable that is assigned on a
login page. In another .cs file (in another directory), I'm trying to use
> if((string)Session["variable"] == "something")
> When I compile, it tells me that Session does not exist in the calss or
namespace.
> My hypothesis is that it is because this directory is compiled before the
directory that actually has the Session variable's declaration. Any ideas
on how to fix this?
> thanks.
> George
Or you can grab the application object and then access the session:
using System.Web; //Need this at top
HttpApplication ha = HttpContext.Current.ApplicationInstance;
string mySessionValue = ha.Session["MySessionValue"];
Very simple:
VB.NET
Dim ha As HttpApplication = HttpContext.Current.ApplicationInstance
Dim mySessionValue As String = ha.Session("MySessionValue")
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
****************************************
********
Think Outside the Box!
****************************************
********
"Michael J. Mooney" <mike_mooney@._yahoo.com.NOSPAM> wrote in message
news:%23tyjDyLTEHA.2336@.TK2MSFTNGP10.phx.gbl...
> "Session" is not a global variable, it is a property of the
> System.Web.UI.Page object.
> When you use Session["variable"] inside an aspx page, it is actually
> translating to this.Session["variable"].
> When you are in another class which is not an aspx page derived off of the
> Page class, it has no access to the Session object.
> You either need to pass a reference to the Session object into your other
> class (yuck), or pass the value itself as a parameter/property/etc.
> --
> Michael J. Mooney
> MCP+SB, MCAD, MCSD
> "George" <anonymous@.discussions.microsoft.com> wrote in message
> news:CE2AB820-0B7C-43E0-BCA6-E3A654E6E18A@.microsoft.com...
> login page. In another .cs file (in another directory), I'm trying to use
> namespace.
the
> directory that actually has the Session variable's declaration. Any ideas
> on how to fix this?
>

Session Variable

I have an application where the default page requires the user to choose the location they are logging into. I take the value (one or two letter designation) and save it to a Session variable. I then access this variable on the page load of all pages in the application and use the value to call stored procedures to display the proper data from the database. The problem is, some users are timing out and lose their session causing them to have to go back to the first page and re-choose their location. I did increase the session timeout to 60 but this may still not be long enough for some users. Is there a better way to do this without using a session variable? Any help and/or example VB code will be appreciated.

Thanks

While navigating to other page assign this value to a hidden field. Then afterwards check the value of hidden field instead of Session variable. Once you are navigating to another page transfer this value in hidden field again to Session.

Let me know if you need any further help


Any session var or app var would be subject to a session timeout. You do not want to extend the timeout too much because it has an adverse effect in resource consumption.

If your security requirements are not too stringent (risk is low), you could use a QueryString (URL) parameter instead. Validate the parameter to make sure nothing fishy comes in before you use it. You could keep the info in a user database and get the data from there when the user first logs in.


Forgot: You could also use Hidden fields (if security is not stringent) or cokkies if accepted in your client browsers.

See:http://msdn2.microsoft.com/en-us/library/z1hkazw7.aspx


I tried the suggestion and am now running into a problem. It works great if the user stays on the same page. The problem is when the user clicks on another page using the link buttons I provide. If the session expires then my variables are not set. I was hoping to set the Session Variables again when the user leaves the page but I'm not sure where to do this. Any more ideas?

What I would recommend is that you use a cookie for your application with a time-out of however many minutes you think you need. Each page would then check the cookie to get the values needed. With those wonderful people, such as myself, that don't allow most cookies, you can always make the page auto-refresh every x number of minutes. That should reset the timer on the session variable. You will have the problem of needing to make sure that data is not resubmitted. Web applications have the drawback of not automatically trusting the user the way a desktop application would.

Session variable

Hello,
How to declare a variable of session without value (empty) ?
Because If I use a page with a Null Session I have the error :
"Object reference not set to an instance of an object."
on this line :
Line 16: Dim SessionUser As String = Session("USER").ToString

Thank you for your help.
PAB.You can use String.Empty for string values
Hello,
Thanks, I try that.
PAB.
C#

if ( Session["User"] == null)
{

// not exists

}

VB.Net

IF SESSION["USER"] is Nothing THEN

// Not Exists.

END IF