.NET interview questions (that you need to master)

Developed by Microsoft in 2002, .NET framework is a largely tested software framework that provides an environment to debug, deploy and run code onto web services and applications.

This framework uses object-oriented programming, taking advantage of tools and functionalities like libraries, classes, and APIs. It has the advantage that many programming languages such as C#, Cobol, VB, F#, Perl, etc. can be used to write.NET framework applications; providing support to services, websites, desktop applications, and many more on Windows. 

This framework has evolved to .NET Core, a newer version of the .NET framework. It has been created as a general-purpose, free, and open-source development platform.  It is a cross-platform framework and therefore is able to run any given application on different operating systems like Windows, Linux, or macOS. Another advantage of .NET core is that can be used to develop applications like cloud, games, IoT, machine learning, microservices, mobile, web, etc. with easy.

So If you are looking forward to getting a job related to this framework, we have selected the most commonly asked .NET interview questions and the respective answers, at both basic and advanced levels. 

We also had included several .NET Code Challenges that will help you to be more prepared for your interview ahead. So when you had mastered our selection, you will be ready to excel in your .NET interview.

Basic .NET questions

Which are the characteristics of .NET Core?

Cross-platform: is supported by different operating systems such as Windows, macOS, and Linux.

Fast: .NET Core 3.0 is faster compared to the .NET Framework, and even faster than other server-side frameworks like Node.js or Java Servlet.

Free and open-source: The source code project can be obtained from Github for free, licensed under MIT and Apache licenses.

Friendly: The .NET Core is fully compatible with .NET Framework, Xamarin, Mono, and through .NET Standard. It can also be used to interact with other Web frameworks and libraries like Angular, JavaScript, or React.

Sharable: API models written in .NET Standard may be used by .NET Core and all the .NET applications, as well on multiple platforms with different languages.

Multiple job opportunities.
One code challenge.

Get rid of repetitive hiring processes for all the positions you apply to, and access many job offers by taking a single real-world assessment.

Explain how the .NET framework works

Any given.NET framework-based application (written in supportive languages like C#, F#, or Visual basic) is compiled to Common Intermediate Language (CIL). This compiled code is then stored as an assembly file, with the.dll or .exe file extension.

When the .NET application runs, Common Language Runtime (CLR) takes that assembly file and converts it into machine code, using the Just In Time (JIT) compiler. In the next step, the machine code can be executed on the specific architecture it is running on.

Explain the different components of .NET

Major .NET components are:

Common Language Runtime (CLR): an execution engine that runs the code and provides services to facilitate the development process. Such processes are exception handling, garbage collection, memory management, security, thread management, and type safety. Programs written for the .NET Framework are executed by the CLR, no matter the original programming language. 

Framework Class Library (FCL): it contains pre-defined methods and properties in order to implement common and complex functions used by .NET applications. This library also provides types for dates, strings, numbers, etc.; and includes APIs for database connection, file reading, and writing, drawing, etc.

Base Class Library (BCL): it has a large collection of library features and functions for implementing programming languages such as C#, F#, Visual C++, etc., in the .NET Framework. The library is divided into the User-defined class library (that includes Assemblies) and the             Predefined class library (containing namespaces).

Common Type System (CTS): CTS specifies a standard of the type of data and value that can be defined and managed in memory during runtime. 

Common Language Specification (CLS): a subset of CTS that is defined as a set of rules and regulations to be followed by every .NET Framework’s language. It gives supports inter-operability or cross-language integration, providing a common platform for interacting and sharing information. 

What are assemblies? How many types are implemented in .NET?

Assemblies are files automatically generated by the compiler. It consists of a collection of types and resources, built to work together and to form a logical unit of functionality. Assemblies are implemented into executable files (.exe) or dynamic link libraries (.dll).

Assemblies in .NET are classified into 2 types:

Private Assembly: accessible only to the application, it needs to be installed in the required application folder to be accessible to the program. 

Shared or Public Assembly: it is used and shared by multiple applications, so only one copy of public assembly is required at the system level, installed in the Global Assembly Cache(GAC).

What are EXEs and DLLs?

EXEs and DLLs are both assembly executable modules. The differences rely on the fact that EXE is an executable file that runs the application for which it is designed. It is produced when the application is built, so the assemblies are loaded directly when run. 

Meanwhile, Dynamic Link Libraries (DLLs) are libraries of encapsulated code, that can be shared and invoked by other programs and applications.

What is MSIL?

MSIL stands for Microsoft Intermediate Language, which is used to provide instructions for calling methods, exception handling, memory handling, storing and initializing values, and other procedures.

Those MSIL instructions are platform-independent, generated by the language-specific compiler. Then, the JIT compiler compiles the MSIL into machine code based on the requirement.

State the differences between ASP.NET and ASP

ASP (Active Server Pages) is different from ASP .NET, since:

ASP.NET has full XML Support.

ASP.NET is fully object-oriented; while ASP is only partially object-oriented.

ASP.NET is used to create dynamic web applications; while ASP is Microsoft’s server-side technology just to create web pages.

ASP.NET uses .NET languages such as C# and VB.NET compiled to MSIL; while. ASP uses VBScript. 

ASP.NET uses the ADO.NET technology to connect and work with databases; while ASP uses ADO technology.

Enumerate the different parts of the assembly.

An assembly is composed of:

Manifest: information about the version of the assembly.

Type Metadata: it contains the binary information of the program.

MSIL: it includes the Microsoft Intermediate Language Code

Resources: List of related files necessary for the assembly.

Define MDI and SDI

    MDI stands for Multiple Document Interface. It let us open multiple windows, having one parent window and many child windows. Components (menu bar, toolbar, etc.) are shared from the parent window.

On the other hand, SDI (Single Document Interface) opens each document in a separate window with its own components. SDI is not constrained to the parent window.

What is caching in .NET?

Caching is storing the data temporarily in the memory, in order to be accessed from there instead of searching it in the original location. Caching increases the efficiency and speed of the application. In .NET, there are three types of caching: data, fragment, and page caching.

What is role-based security in .NET?

Role-based security is a way to implement security measures in .NET, depending on the roles assigned to users within the organization. Inside a given organization, authorization of users is done depending on the roles they play. For instance, Windows have three role-based accesses: administrators, users, and guests.

Advanced .NET interview questions 

What is MVC?

It is the acronym of Model View Controller, an architecture to build .NET applications where:

Model: logical part of the application that handles the object storage and retrieval from the databases.

View: handles the UI part of an application. 

Controller: responsible for the user interactions, the responses to the user input, and rendering the view required for the user interaction.

What is CAS?

Code access security (CAS) is a security model that prevents unauthorized access to the resources, enabling also the users to set permissions for the code. CAS can only be used for managed code, so it will go through checks each time an assembly tries to access the resources.

What is delegate in .NET?

A delegate in .NET works in a similar way to a function pointer in other programming languages like C or C++. It allows the user to encapsulate the reference of a method in a delegate object that can then be given to a program that calls the referenced method. Using a delegate method also allows for creating a custom event in a class.

Mention the validations in ASP.NET

Client-side validation:  The validation takes place on the client-side browser, usually using JavaScript.

Server-side validation: The validation occurs on the server, so it is considered the most secure form of validation. Even if the user bypasses the client-side validation, it will be checked in server-side validation.

Enumerate the events of the page life cycle in .NET

The events in the page life cycle are as follows:

  • Page_PreInit

  • Page_Init

  • Page_InitComplete

  • Page_PreLoad

  • Page_Load

  • Page_LoadComplete

  • Page_PreRender

  • Render

What is cross-page posting in .NET?

Whenever the user clicks on a submit button on a page, the data to be sent is stored on the same page. Cross-page posting implies that the data is stored on a different page. It can be done by the POSTBACKURL property, which causes the postback. Then, the FindControl method must be used to get the values posted on that.

What are HTTP Handlers in ASP.NET?

Every request into an ASP.NET application is handled by a specialized component called HTTP handler. It is the most important component for handling ASP.NET application requests, where each handler creates the page and controls objects. Then, runs the code and renders the final HTML.

The default HTTP handlers for ASP.NET are (.aspx): Handles web pages; (.ascx): Handles web user control pages; (.asmx): Handles web service pages; and (trace.axd): Handles trace functionality.

Mention the different cookie types in ASP.NET

There are two: Session Cookies, which reside on the client machine only for a single session until the user logs out; and Persistent Cookies that remain on the user machine for a certain period of time specified for its expiry, which may be an hour, a month or never.

What are the steps of passport authentication?

In passport authentication, it is first checked if there is any passport authentication cookie. If the cookie is not available, then the application redirects to a passport sign-on page. After all, necessary data is given; the passport service authenticates the details of the user. If they are valid, the details are stored on the client machine; and finally, redirect the user to the requested page.

Mention the five security controls available on ASP.NET

Those are the five security controls made available on ASP.NET:

<asp: Login>: It provides the login capability that enables the users to enter their credentials as login ID and password fields.

<asp: LoginName>: It is used to display the user name who has logged in.

<asp: LoginView>: It provides a variety of views that depends on the template that has been selected.

<asp: LoginStatus>: It is used to check if the user is authenticated or not.

<asp: PasswordRecovery>: When applied, it sends an email to the user and resets the password.

Explain the difference between ExecuteScalar and ExecuteNonQuery

ExecuteScalar is used for fetching a single value and it’s used to return the output value without returning the number of affected rows. Meanwhile, ExecuteNonQuery does not return any value and it is used to execute insert and update statements, returning the number of affected rows.

What does MIME stand for?

MIME is the acronym for Multipurpose Internet Mail Extensions. Is the extension of the e-mail protocol that lets users employ the protocol to exchange files over the internet. Normally, servers insert the MIME header at the beginning of a given web transmission and then the clients make use of this header to select an appropriate player for the header indicated type of data, most of them already built into the web browser.

.NET Code Challenges 

With these challenges, we have reached the end of this article on .NET Interview Questions. We hope that you feel now more confident and remember: make sure you study and practice as much as possible. Good luck with that interview ahead!

Multi-apply: How to apply to many job opportunities with one single Challenge

We have managed to get most of the companies we collaborate with to adopt our Rviewer challenges in their validation process as an official test.

And here's the bomb: This allows us to offer you, at last, Multi-Apply: with a single technical challenge you will be able to access more than one job offer. Yes, you heard it right: MANY job opportunities by taking a SINGLE code challenge.

Master coding interviews for growing tech companies

Discover here the ultimate guide to coding interview processes. Find out how they work and how you can optimize yourself as a developer to attract the attention of tech companies and get better results in their coding interviews.

Related articles

Stay tuned: receive the latest product updates

Subscribe to our newsletter to keep up with the latest trends!