Should I use the System.Web.Caching.Cache class in a WinForms application?

I have seen several blog posts / articles that promote the use of System.Web.Caching.Cache in applications that are not Internet-friendly, however the MSDN documentation states quite clearly that

The Cache class is not intended to be used outside of ASP.NET applications. It was designed and tested for use in ASP.NET to provide caching for web applications. In other types of applications, such as console applications or Windows Forms applications, ASP.NET caching may not work correctly.

Is the documentation wrong or should we really not use this class? If the latter, what could go wrong? Our platform is Winforms / .NET 3.5.

+3
source share
3 answers

Expired or unused cache objects cannot be automatically deleted if the application is not an ASP.NET application. Therefore, if Cache objects are used outside of ASP.NET, the system memory reserved for Cache objects is not freed. You cannot manually call ASP.NET internal methods to clear the cache because the methods are marked as internal and are intended for internal use. Therefore, your decision to use it in an external application at your own peril and risk. System.Web.Caching.Cache Object

Scott Hanselman has an article for more details.

+6
source
Documentation

true, you cannot use asp.net cache in a windows application.

Cache article .

0
source

Source: https://habr.com/ru/post/1707190/


All Articles