Using Cache Data Outside of Pages
public SiteInfo GetSiteInfo()
{
SiteInfo Source;
Source = (SiteInfo)Cache["SiteParams"];
if (Source == null)
{
Source = new SiteInfo(DomainName);
Cache["SiteParams"] = Source;
}
return Source;
}
For some reason it does not like for me to use this inside of a class. The compiler throws an error when I compile it. I then changed the class to extend the UserControl class:
public class DataStore : UserControl
It compiles when I do this, but I get the following runtime error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
The same function works okay within a Page or UserControl on my site. How can I get a method like this one to work in a way that all pages can access it?
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

