How to implement in-memory caching in ASP NET Core

With version 1.0 of the .NET Framework, it was first released in January 2002. So a question comes to mind that which technology we were using before the year 2002 for developing web applications and services? It used to be that developers had to buy expensive software (called Integrated Development Environments, or IDEs) in order to build applications. Companies with more than 5 developers must purchase a license to use Visual Studio, but the cost is competitive with professional IDEs for other platforms.

Interpreted code is not directly executed by the machine, but must be read and interpreted each time before being executed. Compiled code is usually faster and more scalable than interpreted code, and can do anything interpreted code can do. If the data is already available in the cache, the GetAuthorsAsync method of the AuthorRepository class will not be called. To implement caching functionality we’ll use another interface, called ICachedAuthorRepository. The ICachedAuthorRepository interface declares only one method named GetCachedAuthorsAsync(), as shown in the code snippet given below.


First released in 2016, ASP.NET Core is relatively new, but has already received a 2.0 release and is now a stable alternative to Windows-hosted ASP.NET web applications. Developers who know ASP.NET can leverage their existing knowledge of C# and can quickly pick up the framework differences introduced in ASP.NET Core. Another important functionality of ASP.NET is that developers have access to all of the .NET classes and features.

When a browser requests an ASP or ASP.NET file, the ASP engine reads the file, executes
any code in the file, and returns the result to the browser. Both technologies enable computer code to be executed by an Internet server. Joydip Kanjilal is a Microsoft MVP in ASP.NET, as well as a speaker and author of several books and articles. He has more than 20 years of experience in IT including more than 16 years in Microsoft .NET and related technologies.

Not the answer you’re looking for? Browse other questions tagged or ask your own question.

ASP.NET is written using Object Oriented Programming languages such as C# or Object Oriented Programming provides a framework and patterns for code organization and reuse. The Dot Net (.NET) is a software development framework that integrates a number of technologies emerged from Microsoft to develop, run, and deploy web services and web or Windows applications.

why asp net

NuGet allows ASP.NET team to provide new functionality and fixes much easier and faster. In this way, if Microsoft provides an upgrade to any of the packages, you can just upgrade it and that is it. There are also some other technology like Java, PHP, Perl, Ruby on Rails, etc. which can be used to develop web applications. The web applications which are developed using the .NET framework or its subsets required to execute under the Microsoft Internet Information Services(IIS) on the server side. The work of IIS is to provide the web application’s generated HTML code result to the client browser which initiates the request as shown in the below diagram.

Make your web pages more readable:

Microsoft also provides Visual Studio Code, a lighter-weight IDE and editor, which is free for everyone, including corporations. ASP.NET is an open source, server-side web application framework created by Microsoft that runs on Windows and was started in the early 2000s. ASP.NET allows developers to create web applications, web services, and dynamic content-driven websites. Professionals who are working with .NET and ASP.NET are up-to-dated with the key differences.

why asp net

Hemant Deshpande, PMP has more than 17 years of experience working for various global MNC’s. He has more than 10 years of experience in managing large transformation programs for Fortune 500 clients across verticals such as Banking, Finance, Insurance, Healthcare, Telecom and others. During his career he has worked across the geographies – North America, Europe, Middle East, and Asia Pacific. Hemant is an internationally Certified Executive Coach (CCA/ICF Approved) working with corporate leaders. He is passionate about writing and regularly blogs and writes content for top websites.

Create a decorator class with caching functionality

The two new properties added in the Page class are MetaKeyword and MetaDescription.

  • Connect and share knowledge within a single location that is structured and easy to search.
  • In the CachedAuthorsAsync methods, data retrieved for the first time is stored in the cache before it is returned.
  • The popularity of ASP.NET makes online resources and skilled developers easy to find.
  • For example services.AddMvc() adds the services required to enable the MVC functionality and middleware in the application.

Naturally, for a real-world application, you would change this implementation to retrieve records from a database. You will be amazed at the performance boost you get when you read cached data instead of hitting a database to retrieve the data. Note how dependency injection is used in the AuthorCachingDecorator class to retrieve an instance of type IAuthorRepository. why asp net This instance is used to retrieve the data by calling the GetAuthorsAsync method pertaining to the AuthorRepository class. Now create a new class named AuthorRepository in a file having the same name with a .cs extension and enter the following code in there. By minimizing calls to thе original data sourcе, a cached repository improves application rеsponsivеnеss.


There are different types of libraries with all the components to help developers and create applications. Also, to create web applications ASP.NET provide the 3 development styles which are ASP.NET Web Pages, ASP.NET MVC, Web Forms. Matt has over 15 years of web development and agency management experience. Starting his career on CSC’s elite R&D team testing leading edge platforms, Matt learned the importance of establishing standardized processes for developing web sites. At Embarc, a leading builder of web presences for biotech companies, Matt rose from developer to Director of Technology and board member. He went on to build and run, winner of PC Magazine Editor’s Choice for wiki services, which was acquired by Wakefly in 2011.

why asp net

Next, create an interface named IAuthorRepository that contains the declaration of the methods corresponding to the operations supported by our repository class. Adding services to this container will make them available for dependency injection. ConfigureServices is primarily for DI and setting up various library setup included for your project. For example services.AddMvc() adds the services required to enable the MVC functionality and middleware in the application.

What Are .NET Core and ASP.NET Core, and Why Were They Created?

There are a lot of discussions in GitHub threads on the subject of porting .NET Framework libraries to .NET Core, and this is a really good example of how open source may impact project development. Obviously, there will be technologies that will not be ported at all, since they are related to Windows operating system when .NET Core was made to provide cross-platform support. You still can use frameworks like MVC, Web API, SignalR, and their syntax is not going to change extremely, as well as business logic written using Entity Framework. It is also still the same C#, F#, etc. code, and the .NET Framework is behind these all. Thirdly, .NET Framework has gradually refused the idea of completely separating side-by-side installations by having no separation between minor version and sometimes even major versions. For example, applications with two different versions of the .NET Framework will coexist with the risk of sharing dependencies, which can cause problems.

Leave a Reply

Your email address will not be published. Required fields are marked *