469,592 Members | 1,869 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Session problem with ASPX

Hi,

I am a programmer and I have a question about a ASP.NET peace of code.

I have a program that has a session timeout of 2 minutes configured in
Web.config file:

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="2"
/>

In the code behind of my Main.aspx I have this C# peace of code:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("<META HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">");
// Retreaves the current user
// the user has been created in the Session_Start() of Global.asax
with the SQLServer connection
user = (Usager)Session[ "User" ];
if (IsPostBack)
{
// Retreives the department list from the session instead of the SQL
connection
arrayDept = (ArrayList)Session[ "ArrayDept" ];
}
else // Initial Load
{
arrayDept = new ArrayList();
DisplayDepartments();
LoadCustomers();
}
// Validate if the session has expired
if (arrayDept == null)
{
Response.Write( "Your Session as expired. Please close your browser
and relog to the site."
Response.Write("<SCRIPT
language=javascript>window.close();</SCRIPT>");
Response.End();
}
else
{
// Create an adapter and populate the dataset
CreateAdapter();
LoadDataSet();
ManageAccessRights();
}
}

Now if I load this site, wait 2 minutes and click somewhere on the page, the
“Your session as expired…” message appears. Since in trying to force the IE
window to close I get the standard “the Web page you are viewing is trying to
close the window. Do you want to close the window?” message. Is chose NO.
Then I click the IE BACK button, do a REFRESH, click yes to the standard
“...you must resend the information…” message and I get back to the exact
page where I was with my session reactivated.

I’m an old fashion ASP expert but I’m kind of new with this ASP.NET thing.
I’ve been struggling with this problem for a couple of days now.

Do you have any idea what may be the cause of this problem?

Thanks.
--
Steph
Jul 27 '06 #1
3 1404
When you refresh the original page, then that is not a postback (because
this is just a GET). That reloads the array. So the page looks just like it
did when you browsed to the page the first time.

At least this is my understanding of what you are doing.

"Steph" <St***@discussions.microsoft.comwrote in message
news:57**********************************@microsof t.com...
Hi,

I am a programmer and I have a question about a ASP.NET peace of code.

I have a program that has a session timeout of 2 minutes configured in
Web.config file:

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="2"
/>

In the code behind of my Main.aspx I have this C# peace of code:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("<META HTTP-EQUIV=\"PRAGMA\"
CONTENT=\"NO-CACHE\">");
// Retreaves the current user
// the user has been created in the Session_Start() of Global.asax
with the SQLServer connection
user = (Usager)Session[ "User" ];
if (IsPostBack)
{
// Retreives the department list from the session instead of the
SQL
connection
arrayDept = (ArrayList)Session[ "ArrayDept" ];
}
else // Initial Load
{
arrayDept = new ArrayList();
DisplayDepartments();
LoadCustomers();
}
// Validate if the session has expired
if (arrayDept == null)
{
Response.Write( "Your Session as expired. Please close your browser
and relog to the site."
Response.Write("<SCRIPT
language=javascript>window.close();</SCRIPT>");
Response.End();
}
else
{
// Create an adapter and populate the dataset
CreateAdapter();
LoadDataSet();
ManageAccessRights();
}
}

Now if I load this site, wait 2 minutes and click somewhere on the page,
the
"Your session as expired." message appears. Since in trying to force the
IE
window to close I get the standard "the Web page you are viewing is trying
to
close the window. Do you want to close the window?" message. Is chose NO.
Then I click the IE BACK button, do a REFRESH, click yes to the standard
"...you must resend the information." message and I get back to the exact
page where I was with my session reactivated.

I'm an old fashion ASP expert but I'm kind of new with this ASP.NET thing.
I've been struggling with this problem for a couple of days now.

Do you have any idea what may be the cause of this problem?

Thanks.
--
Steph

Jul 27 '06 #2
How do I test if the session is expired?
--
Steph
Jul 27 '06 #3
You can test Session.IsNewSession to see if this session has just been
started with the current request.

"Steph" <St***@discussions.microsoft.comwrote in message
news:7F**********************************@microsof t.com...
How do I test if the session is expired?
--
Steph


Jul 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Scott | last post: by
4 posts views Thread by Kent Tegels | last post: by
2 posts views Thread by Joe Molloy | last post: by
4 posts views Thread by Igor | last post: by
1 post views Thread by Werner | last post: by
4 posts views Thread by DavidS | last post: by
13 posts views Thread by Alexander Widera | last post: by
3 posts views Thread by catweezle2010 | last post: by
7 posts views Thread by Mr Newbie | last post: by
2 posts views Thread by Ned Balzer | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.