Saturday, March 31, 2012

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 times out too soon...

Friends,
My web.config session setting is timeout=20, but in code we set the timeout
to override this to some user preference, often 40 minutes, (specified by
the user in seconds). But even in fairly active sessions, (ones where post
are done every 5 minutes or less), we still have session timing out.
Whether either the 20 minute or 40 minute value is in effect, I never wait
more than 5 minutes between posts back to the server (doing real work) so I
would NOT expect a session timeout.
Does anybody have any ideas about how to track this down? Are others having
similar results? Do I need to provide more data to make sense?
Thanks in advance for your time. I've been in software for 20+ years, but
new to ASP.NET. Our actual ASP.NET developers are baffled too.
Thanks! Sincerely,
James Hunter Ross
Senior Software Developer
O'Neil Software, Inc.
james.ross@dotnet.itags.org.oneilsoft.comJames Hunter Ross wrote:
> Friends,
> My web.config session setting is timeout=20, but in code we set the
> timeout to override this to some user preference, often 40 minutes,
> (specified by the user in seconds). But even in fairly active
> sessions, (ones where post are done every 5 minutes or less), we
> still have session timing out. Whether either the 20 minute or 40
> minute value is in effect, I never wait more than 5 minutes between
> posts back to the server (doing real work) so I would NOT expect a
> session timeout.
If you really are seeing Session loss (instead of something else that only
looks like Session loss), the most common cause would be an app domain
restart, assuming you are using InProc Session state.
Check the ASP.NET v1.1.4322 object in perfmon. There is a counter for
Application Restarts. Monitor that when you lose Session. If it increments
at the same time, your app domain recycling is causing the problem.
The most common cause of app domain restarts is file change notifications.
That would be caused by anti-virus or something else scanning the
application or from someone changing the web.config in the root folder or
something in the bin.
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com
FrontPage add-ins for FrontPage 2000 - 2003

I also experienced this issue and found Jim's post regarding
sessionState mode to be helpful.
I changed my sessionState mode from the default inproc to StateServer.
Of course, this is one of those situations where, after the change, I'm
waiting for the application to, uh, NOT break. But so far so good.
One question I had for Jim is about perfmon. This looks like a really
neat tool - I just wish I knew how to use it.
When you say to 'Check the ASP.NET v1.1.4322 object in perfmon' - how
does one do that?
Cheers,
Robert Meyer
ISG
http://www.isgcom.com
*** Sent via Developersdex http://www.examnotes.net ***
Robert Meyer wrote:
> When you say to 'Check the ASP.NET v1.1.4322 object in perfmon' - how
> does one do that?
>
Hi Robert,
Perfmon (Performance) is in Administrative Tools. When you launch it,
choose "ASP.NET v1.1.4322" from the object dropdown. That will populate the
Counter and Instance listboxes. Choose "Application Restarts" from the
Counter listbox and then choose your process (or Global) from the instance
listbox. Then click Add and then Close.
Now you will have an item in the listbox at the bottom of Perfmon for
Application Restarts. If you select it, you'll see a graph representation
and numeric values for that counter. If you see that increment when your
problem occurs, you'll know it was because of an app domain restart.
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

Session timing problem

in ASP.NET 1.1, I want to keep my session alive for a while.

I add an object to session (Session.Add()) and set the session timeout in the web.config for 20 minutes however it seems to lose the session after 5 minutes (well before 20 minutes) or after a few refreshes of the page.

any ideas how I can keep the session alive for longer fully until the time specified in the web.config?Might be a problem with the ASP.NET worker process. Check your Event Viewer first to see if W3WP or any related processes have errored out, which may be causing the worker process to recycle (therefore ending the session)
i doubt that is the issue as the same problem happens when i upload it to my web hosting server. :)

Session tracked via URL in ASP.NET

Hello,

I have my asp.net web application to track session id across pages using the url, and not cookies, ie in the web.config file:
<sessionState .... cookieless="true" ...... />

however each link in the page does not embed the id in the url like it is supposed to :

<a href="http://links.10026.com/?link=http://mywebserver/(rqe4ptb333ojxz3kh1t3xqr3)/mypage.aspx"> my link </a>

and so each page i travel to, a new session id is created in the url and the information associated with the previous page's session id is lost.

can anybody tell me what else i need to do to make this work?

thank you,

Kenton Taylorfor some reason the .net framework will not insert the session id before rendering the HTML if your HREF uses a "/" to denote that the path is relative to the root

this will work:
href="http://myserver/home.aspx"

as will this:
href="home.aspx"

but this won't:
href="/home.aspx"

Session timout problem

I can't get WebForm1 to load load automatically after a session timeout, with the following code. How can I do so

In Web.config

<sessionState
mode="InProc
timeout="1"
/

In Global.asax.cs

protected void Session_End(Object sender, EventArgs e

Response.Redirect("WebForm1.aspx")
}i think you do not have to use

timeout = "1"

use

timeout= 1
"mg" <mg@.theworld.com> wrote in message
news:4EB06580-0453-4278-901B-F7D7F34397CE@.microsoft.com...
> I can't get WebForm1 to load load automatically after a session timeout,
with the following code. How can I do so?
> In Web.config:
> <sessionState
> mode="InProc"
> timeout="1"
> />
>
> In Global.asax.cs:
> protected void Session_End(Object sender, EventArgs e)
> {
> Response.Redirect("WebForm1.aspx");
> }
The session_end does not initiate another http request if that's what you're
thinking. However, on the next request the client makes, it should activate
the session_end -- although there are known issues with that. You cannot
always rely on that triggering... do a search for that session_end sub --
also note that in an earlier version of .net that sub's name is different.
In my tests, one works, the other doesn't. I don't know if it's bugged or
what!

-Max

"mg" <mg@.theworld.com> wrote in message
news:4EB06580-0453-4278-901B-F7D7F34397CE@.microsoft.com...
> I can't get WebForm1 to load load automatically after a session timeout,
with the following code. How can I do so?
> In Web.config:
> <sessionState
> mode="InProc"
> timeout="1"
> />
>
> In Global.asax.cs:
> protected void Session_End(Object sender, EventArgs e)
> {
> Response.Redirect("WebForm1.aspx");
> }
sorry timeout="1" is ok in web.config but not if used in aspx page ,in aspx
page it would be session.timeout=1
"Ismail Rajput" <human_to_human@.hotmail.com> wrote in message
news:uF4LmNY%23DHA.3828@.TK2MSFTNGP10.phx.gbl...
> i think you do not have to use
> timeout = "1"
> use
> timeout= 1
> "mg" <mg@.theworld.com> wrote in message
> news:4EB06580-0453-4278-901B-F7D7F34397CE@.microsoft.com...
> > I can't get WebForm1 to load load automatically after a session timeout,
> with the following code. How can I do so?
> > In Web.config:
> > <sessionState
> > mode="InProc"
> > timeout="1"
> > />
> > In Global.asax.cs:
> > protected void Session_End(Object sender, EventArgs e)
> > {
> > Response.Redirect("WebForm1.aspx");
> > }
here is an article to sort out the confusion
http://www.developersdex.com/gurus/articles/746.asp

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Max" <maximus@.portvista.com> wrote in message
news:eQ8_b.66744$jH.539124@.twister.tampabay.rr.com ...
> The session_end does not initiate another http request if that's what
you're
> thinking. However, on the next request the client makes, it should
activate
> the session_end -- although there are known issues with that. You cannot
> always rely on that triggering... do a search for that session_end sub --
> also note that in an earlier version of .net that sub's name is different.
> In my tests, one works, the other doesn't. I don't know if it's bugged or
> what!
> -Max
>
> "mg" <mg@.theworld.com> wrote in message
> news:4EB06580-0453-4278-901B-F7D7F34397CE@.microsoft.com...
> > I can't get WebForm1 to load load automatically after a session timeout,
> with the following code. How can I do so?
> > In Web.config:
> > <sessionState
> > mode="InProc"
> > timeout="1"
> > />
> > In Global.asax.cs:
> > protected void Session_End(Object sender, EventArgs e)
> > {
> > Response.Redirect("WebForm1.aspx");
> > }

Session Tuturorial or Walkthrough for a newbie?

I am looking for a good walk through or tutorial on setting up session
managment or some kind of state managment.
This is what I am doing, so maybe you can tell me which direction I should
look at going!
I have a app then once you fill in your query information and sumitt the
form you get my results page. On the results page I have a datagrid that
contains anywhere from 5 to 7000 rows that are shown in a OutLookGroup style
.
I am finding that the table the grid builds off is very large to maintain in
viewstate, sometimes 12mb+. What I would like to do is in my grid only keep
what I need to display the grid and my row ID field, but I need to store the
entire table (which is created on the fly based on the query) in state
somehow, then call back to it on post to retrieve my details to further
process the page.
So I guess I need to do the following,
1. create the session (or whatever)
2. process the query and save table to session
3. onclick function retrieve the table from session and do secondary query
4. contrinue to maintain the table in session
5. after timeout dispose/flush table.
Can anyone give me good direction on where I go to make this happen?
Thanks;
--
D @dotnet.itags.org. premierdataHi Dewright,
AS for the caching table question you mentioned, I think generally the
following code the what we commonly used:
DataSet ds = null;
if(Session["data_key"] == null)
{
QueryDataFromDataBaseAndStoreIntoSession
();
}
ds = Session["data_key"] as DataSet;
We can put it in Page_load and bind the grid when necessary(We may adjust
the code according to our actual code logic). Also , for large dataset, of
course we suggest disabling the DataGrid's ViewState and bind grid with
data retrieved from SessionState(or other cache store) in each
request/postback.
Also, how do you think of the ASP.NET's Cache collection? Each ASP.NET
application will has a Cache colleciton assosciated with it, (it's
application scope ), we can store datas in it and add a expire dependency
for it. So for your scenario, you can also consider storeing the large data
records in Cache (with a sessionid associated key if necessary).
Here are some good resources for understanding the SessionState and Cache
in ASP.NET:
#Understanding session state modes + FAQ
http://forums.asp.net/7504/ShowPost.aspx
#State Management & Caching
http://msdn.microsoft.com/asp.net/a...te/default.aspx
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)