Search code examples
static-class

Is static class similar to cache or session


Is it possible in asp.net web application(intranet) to use static class instead of Session, Cache, (or) Cookies ...

Currently in my new project, i am using a static class and storing all the needed data across multiple pages in this class as hashtables. It works fine and so far i have faced no issues.

Is it possible to use like this.? Will it cause any issues like data getting deleted like how it happens in cache or session expiration.?

In which possible cases, can i expect any issues. Can anyone please clarify this.

Thanks in advance


Solution

  • You cannot use a simple static class like a session or cache. After a page postback all data in your class is forgotten. You need to store your data in a session or cache or application value. cache and application is for global use.