10X Sale
kh logo
All Courses

Introduction

ASP.NET is a web application framework developed to build dynamic web applications, web services, and web APIs. It is part of the .NET framework and allows developers to create powerful, data-driven websites using various programming languages, including C#, VB.NET, and F#. Our expansive set of ASP.NET interview questions is made for both beginners and advanced-level interviewees. The questions are divided widely, covering topics like Routing and URL management, MVC, MVVM, Web Forms, MVC, and Web API programming models, Cookies, Sessions, Cache, and Testing. Our set of ASP.NET interview questions and answers will make you confident to sit and ace the interview.

ASP.NET Interview Questions and Answers
Beginner

1. What are the types of state management is ASP.NET?

1. Client side:

  1. Hidden Field
  2. ViewState
  3. Cookies
  4. Control State
  5. Query Strings

2. Server side:

  1. Session
  2. Application
  3. Cache

2. What is ViewState in ASP.NET?

ViewState is a client-side state management mechanism in ASP.NET. It is a default technique used by ASP.NET to persist the value of the page and controls during postbacks.

In ASP.NET ViewState the values are encrypted and stored in a hidden field ( named _VIEWSTATE) on the page as an encoded Base64 string. By default, ViewState is sent to the client browser and then returned to the server in the form of a hidden input control on your page.

3. What are the advantages and disadvantages of ViewState?

Advantages:

  • It works at client side so it doesn't put any load on the server 
  • Easy to implement
  • ViewState ensures security because it stores the data in encrypted format.

Disadvantages:

  • It can be performance overhead if we are going to store a larger amount of data because it is associated with page only.
  • Does not track across pages. ViewState information does not automatically transfer from page to page.
  • A good hacker can get the data very easily by decoding the value of the ViewState. One can’t store sensitive data in the ViewState.
  • It does not have any support for mobile devices.

4. Does ViewState affect performance? What is the ideal size of a ViewState? How can you compress a ViewState?

It's no surprise that this one pops up often in ASP.NET interview questions and answers for freshers.

If the application is storing a lot of data in ViewState, it can affect the overall responsiveness of the page, thereby affecting performance since data is stored on the page itself in hidden controls.

The ideal size of ViewState should be less than 30% of the page size.

DeflateStream and GZipStream are the classes in ASP.NET that provide methods and properties to compress and decompress streams. Using these classes to compress ViewState will reduce its size to around 40%.

5. What are the types of caching in asp.net? Explain.

  • Page Output Caching:

It keeps a copy of the response that was sent to the client in memory and subsequent requests are then responded with the cached output until the cache expires, which incredibly improves the ASP.NET web application performance. It is implemented by placing an OutputCache directive at the top of the .aspx page at design time.

Example: 

<%@OutputCache Duration="10" VaryByParam= "Id"%>
  • Page Fragment Caching:

Sometimes we might want to cache just portions of a page. For example, we might have a header for our page which will have the same content for all users.  To specify that a user control should be cached, we use the @OutputCache directive just like we used it for the page.

<%@OutputCache Duration=10 VaryByParam="None" %>
  • Data Caching:

Data Cache is used to store frequently used data in the Cache memory. It's much efficient to retrieve data from the data cache instead of database or other sources. We need use System.Web.Caching namespace. The scope of the data caching is within the application domain unlike "session". Every user can able to access these objects.

  • Create: Cache["Employee"] ="DatasetName";
  • Retrieve: Dataset dsEmployee = (Dataset) Cache ["Employee"]

Want to Know More?
+91

By Signing up, you agree to ourTerms & Conditionsand ourPrivacy and Policy

Description

ASP.NET Core is a free and open-source framework that is widely adopted for its easy updates, high-speed performance, and command-line application that allows it to execute, create, and host several applications, easy maintenance, and cross-platform capabilities. It is a framework of the future, and there is a huge demand for professionals in this field. To learn more, you can join the best programming courses with KnowledgeHut to widen your horizons.

Won’t a set of detailed FAQs boost your confidence to crack your ASP.NET interview? We have compiled a few questions and answers on ASP.NET, which will help you to showcase your knowledge to your employer on concepts that lie around it. The following interview questions for ASP.NET will surely help you to prepare and qualify for your ASP Net Core developer role. If you want to develop more knowledge and a firm base regarding ASP.NET, enroll in our Asp-Net Course and build your career's foundation.

Recommended Courses

Learners Enrolled For
CTA
Got more questions? We've got answers.
Book Your Free Counselling Session Today.