473,372 Members | 1,228 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 1532
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Scott | last post by:
Hello, we are having problems displaying non-aspx files (images, style sheets) since we have upgraded to the 1.1 framework when using a cookieless session (sessionID in the url). Check out...
4
by: Kent Tegels | last post by:
Okay, so I know I'm doing two evil things: using Frames and storing stuff in Session. I'm a sinner and I'll repent after this project, I promise. But for now, I've got an interesting issue. ...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
4
by: Igor | last post by:
Is it possible to point current context's session to another active session based on a SessionID?
1
by: Werner | last post by:
Hi Patrick! Can you give an example of how to use a frameset inside an aspx-file? When I create a new frameset in Visual Studio.Net it just gives me a htm-File. Or give me a link where I can...
4
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
13
by: Alexander Widera | last post by:
hi, who has seen the follow problem or could help please? i visit a page .... i read a sesssion-var . ... everythink works...... i visit the page again..... error ... the sessionvar is null .... i...
3
by: catweezle2010 | last post by:
Hello NG, I have three files (default.aspx, search.aspx and work.aspx). The way is: login on default (if session is newsession). The loginname I write into as sessionvariable (username). So I...
7
by: Mr Newbie | last post by:
I have written a Custom Control Menu. Its fairly simple but it works well enough. In order to simplify things I decided to store the Menu1 custom control in Session. In the page load event below,...
2
by: Ned Balzer | last post by:
Hi, Apologies if this is a newbie question, I haven't found the answer in any faqs. I have an asp.net 2.0 page that sets session variables and then redirects to another page. For the page...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.