473,326 Members | 2,805 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,326 software developers and data experts.

HttpApplicationState data being lost

We have an ASP.NET 2.0 web site, running on IIS version 6.0, Windows 2003
server. On the Application_Start event of the Global.asax.cs, we load
configuration values to the HttpApplicationState dictionary, to be used
throughout by all web site pages, on a read-only fashion.

The problem we are experiencing is that, after running for some hours, the
values of the HttpApplicationState are lost. Our code never assumes there is
a possibility that the golbal data is not there, so it crashes with a
NullReferenceException exception.

So for instance, we have this line of code in the Global.asax.cs:

protected void Application_Start(Object sender, EventArgs e)
{
Application["SiteName"] = " Our web site";
}

And we have this kind of code in our ASP.NET pages.

string siteName = Application["SiteName"];

I know that if you are using the ASP.NET Cache object, you are supposed to
check if the data is still there, since it could have already been scavenged.

But I expected the HttpApplicationState not to have this issue, so our code
would never need to check if data was still there.

I thought the only time HttpApplicationState data would be reset would be
when the web site Application Domain was shut down (either due to ASP.NET
worker process reset or IIS reset).

But in this case, I was expecting the Application_Start event to be
triggered again upon the first request after the Application Domain shut
down, so the data would be loaded again to the HttpApplicationState
dictionary.

Is there any circumstance where HttpApplicationState dictionary entry may be
reset or scavenged during the lifetime of ASP.NET Application Domain, like it
happens with the Cache entries?
Sep 16 '08 #1
1 2798
you can make a static class

class X{
static public string SiteName{
get{
if(Application["SiteName"]==null)
Application["SiteName"] = " Our web site";
return Application["SiteName"] ;
}
}
}

in this case ,if the app/host doesn't reset. Application["SiteName"] will
be load once.as same as in application_start,and it's not load the data at
the host start up,but you use it first
----------------------------------------------------------

"mnowosad" <mn******@discussions.microsoft.com写入消息
news:7D**********************************@microsof t.com...
We have an ASP.NET 2.0 web site, running on IIS version 6.0, Windows 2003
server. On the Application_Start event of the Global.asax.cs, we load
configuration values to the HttpApplicationState dictionary, to be used
throughout by all web site pages, on a read-only fashion.

The problem we are experiencing is that, after running for some hours, the
values of the HttpApplicationState are lost. Our code never assumes there
is
a possibility that the golbal data is not there, so it crashes with a
NullReferenceException exception.

So for instance, we have this line of code in the Global.asax.cs:

protected void Application_Start(Object sender, EventArgs e)
{
Application["SiteName"] = " Our web site";
}

And we have this kind of code in our ASP.NET pages.

string siteName = Application["SiteName"];

I know that if you are using the ASP.NET Cache object, you are supposed to
check if the data is still there, since it could have already been
scavenged.

But I expected the HttpApplicationState not to have this issue, so our
code
would never need to check if data was still there.

I thought the only time HttpApplicationState data would be reset would be
when the web site Application Domain was shut down (either due to ASP.NET
worker process reset or IIS reset).

But in this case, I was expecting the Application_Start event to be
triggered again upon the first request after the Application Domain shut
down, so the data would be loaded again to the HttpApplicationState
dictionary.

Is there any circumstance where HttpApplicationState dictionary entry may
be
reset or scavenged during the lifetime of ASP.NET Application Domain, like
it
happens with the Cache entries?

Sep 17 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fabian Kr?ger | last post by:
Hello, I got a weird problem and need your help and ideas... Ive written an php application which imports data in XML format and writes this data to a MySQL database to have a faster access....
0
by: Bob Reader | last post by:
I am new to multithreading concepts and want to ensure i am doing the following correctly: I am planning to create a custom object and store it in the HTTPApplicationState of an ASP.Net...
0
by: CJ | last post by:
Hi We have Session Data lost randomly and Session State expired early. Our Intranet Application uses Window Server 2003 and .Net Framework 1.1. We set Session Time out to 60 minutes. but user...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
7
by: Neil Ginsberg | last post by:
I'm having some problems with an Access 2000 MDB file with a SQL Server 7 back end, using ODBC linked tables. I previously wrote about this, but am reposting it with some additional information and...
5
by: Natan | last post by:
Hi! I have an object stored in the HttpApplicationState collection of my site, but i would like to mantain the state of this object even if the application restart, so in case of any problem or...
0
by: Ajay Choudhary | last post by:
Hi, I have a custom SoapExtension class and in the "ProcessMessage" method I would like to get a handle of HttpApplicationState object. How can I do that ? Thanks, Ajay
2
by: moi | last post by:
Hello, Dim strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Application.StartupPath & "\app_data\aaaaaa.mdb;" Application.StartupPath does'nt work with ASP.NET 2 : ...
0
by: Winder | last post by:
Computer Data Recovery Help 24/7 Data recovering tools and services is our focus. We will recover your data in a cost effective and efficient manner. We recover all operating systems and media....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.