Asp.NET Interview questions with answers on Application, Cache and Outputcache

What is caching?

Caching is the technique of storing frequently used items in memory so that they can be accessed more quickly

Is it session level state management or application level

Application level.

What directive is used to cache a web form?

The @OutputCache page directive is used to cache a Web form in the server’s memory.

Is it possible to cache multiple responses of same web form?

You can use either VaryByParam, VaryByHeaders or VaryByCustom attributes of the outputcache directive in order to achieve this.

Is it possible to store objects in cache?

Yes for that we can use cache object of Page Class. It’s a key value pair collection.

How Page.Cache is different from application?

Cache provides features like dependencies and expiration policies. If you don’t specify expire time for the cache item, you don’t know when it will be expired. Whereas the Application object will live until the last user leaves the application. If you put an object in cache, it not guaranteed to be there when you fetch it. The cache is free to throw it away if the cache get too large which is not the case with Application object.

How to access them outside aspx?

If you are in aspx page you can access it easily using cache property of page class where as if you are in some other user defined class you can access it as HttpContext.Current.Cache.

What is the difference between HttpRuntime.Cache vs. HttpContext.Current.Cache ?

Well, both will do the same thing. But HttpRuntime.Cache is recommended one because it has a slight performance benefit plus it will also be available when you write unit tests.

See more such ASP.NET interview questions with answers from and also there is a nice article on which has a great list of ASP.NET interview questions  



About c# and .NET Interview questions

This blog is for developers who want to crack .NET and C# interviews. It has all tips and tricks needed to crack .NET interviews , C# interview , SQL Server interview , Java interview , WCF Interview , Silverlight interview , WPF interview , LINQ interview , Entity framework Interview. Do not forget to watch our Learn step by step video series. Learn MVC in 16 hours:- Learn AngularJS Step by Step:- Learn Design Pattern in 8 hours:- Learn C# and .NET in 60 days:- Learn MSBI in 32 hours:- Learn SharePoint Step by Step in 8 hours:-
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s