can't access: System.Web.HttpContext.Current.Cache

X

xzzy

A. I need to access: System.Web.HttpContext.Current.Cache

but get this error:

"Object reference not set to an instance of the object"

B. System.Web.HttpContext.Current.Cache is accessible outside of this
class.



I have listed the code below and the offending line of code is delimited by

//The next line breaks: "Object reference not set to an instance of
the object"



Thank you,

John Bickmore

+++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++

using System;
using System.Threading;
using myclasses;

namespace mrFooter
{
public class mrFooter
{
public Thread myThread;

//Parameter(s) go here
string ySessionUser = "";
string yCookieUserEmail = "";

public void Update(string xSessionUser)
{
// init values
ySessionUser = xSessionUser;

CookieUtil myCookie = new CookieUtil();
yCookieUserEmail = myCookie.GetUserEmail();

myThread=new Thread(new ThreadStart(UpdateCache));
myThread.Start();
}

private void UpdateCache()
{
string sUser = "";
bool Continue = true;

try
{
while ( Continue )
{
if ( ySessionUser == null || ySessionUser == String.Empty)
{
Continue = false;
}
else
{

if ( yCookieUserEmail == ySessionUser )
{

//the next line breaks: "Object reference not set to an instance of the
object"
sUser = (string)System.Web.HttpContext.Current.Cache[ySessionUser];
//the previous line breaks: "Object reference not set to an instance of the
object"

Thread.Sleep(System.TimeSpan.FromMilliseconds(110000));
Continue = true;
}
else
{
Continue = false;
}
}
}//end while
}// end try
catch(Exception err)
{
Continue = false;
clsErrorsIO myError = new clsErrorsIO();
myError.errMessage = "Error while reading cache";
myError.errNumber=0;
myError.errSourceObject = "clsUpdateFooter";
myError.errSourceEvent = "Update";
myError.errSourceMsg = err.Message.ToString();
myError.ErrorAdd();
}
finally
{
}
}
}//end of class: mrFooter
}//end of Namespace: clsUpdateFooter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top