By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

Session problem with ASPX

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
How do I test if the session is expired?
--
Steph
Jul 27 '06 #3

P: n/a
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.