Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the difference between IIS and Kestrel? Why do we need two web servers?

Answer»

The main difference between IIS and Kestrel is that Kestrel is a cross-platform server. It runs on Windows, Linux, and Mac, whereas IIS only runs on Windows.

Another essential difference between the two is that Kestrel is fully open-source, whereas IIS is closed-source and developed and MAINTAINED only by Microsoft.

IIS is very old software and comes with a considerable legacy and bloat. With Kestrel, Microsoft started with high-performance in MIND. They developed it from SCRATCH, which allowed them to ignore the legacy/compatibility issues and focus on speed and efficiency.

However, Kestrel doesn’t provide all the rich functionality of a full-fledged web server such as IIS, Nginx, or APACHE. HENCE, we typically use it as an application server, with one of the above servers acting as a reverse proxy. 

2.

What is Kestrel?

Answer»

Kestrel is an open-source, cross-platform web SERVER designed for ASP.NET Core. Kestrel is included and ENABLED by default in ASP.NET Core. It is very light-weight when compared with IIS.

Kestrel can be used as a web server PROCESSING REQUESTS directly from a network, including the Internet.

Though Kestrel can serve an ASP.NET Core application on its own, MICROSOFT recommends using it along with a reverse proxy such as IIS, Nginx, or Apache, for better performance, security, and reliability.

3.

What is IIS?

Answer»

IIS stands for Internet Information Services. It is a POWERFUL web server developed by MICROSOFT. IIS can also act as a load balancer to distribute INCOMING HTTP requests to different APPLICATION servers to allow high reliability and scalability.

It can also act as a reverse proxy, i.e. accept a client’s request, forward it to an application server, and return the client’s response. A reverse proxy improves the security, reliability, and performance of your application.

A limitation of IIS is that it only runs on WINDOWS. However, it is very configurable. You can configure it to suit your application’s specific needs.

4.

What is the purpose of the appsettings.json file?

Answer»

Appsettings.json CONTAINS all of the application's settings, which ALLOW you to configure your application behavior.

Here is an EXAMPLE of an appsettings.json file.

{ "Logging": { "LOGLEVEL": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } },"ConnectionStrings": { "AppConnection": ""},"AWS": { "Profile": "local-test-profile", "Region": "us-west-2"},"AllowedHosts": "*"}
5.

What is the purpose of the wwwroot folder?

Answer»

The wwwroot folder CONTAINS static files and compiled ASSETS, such as JavaScript, CSS, and IMAGES that your web application needs. Wwwroot is the only folder in the ENTIRE project that's exposed as-is to the browser. 

6.

What is the purpose of the Startup class?

Answer»

This class handles two important aspects of your application, namely SERVICE registration, and middleware PIPELINE.

Services are C# classes that your application depends on for providing additional functionality, both used by the framework and your application. Examples include logging, database, etc. These services must be registered to be instantiated when your app is RUNNING and when it needs them.

The middleware pipeline is the sequence in which your application processes an HTTP request (the next question explains the concept of Middleware in detail).

Startup class contains two methods: ConfigureServices() and Configure(). As the name suggests, the first METHOD REGISTERS all the services that the application needs. The second method configures the middleware pipeline.

7.

What is the purpose of the Program class?

Answer»

Program.cs class is the entry point of our APPLICATION. An ASP.NET application starts in the same way as a console application, from a static void Main() function.

This class configures the web host that will serve the requests. The host is responsible for application startup and lifetime management, including graceful shutdown.

At a minimum, the host configures a SERVER and a request processing PIPELINE. The host can also set up logging, CONFIGURATION, and dependency injection.

8.

What is NuGet package manager?

Answer»

Software developers don’t write all code from scratch. They rely on libraries of code written by other developers. Any modern development platform must provide a mechanism where developers can download and use EXISTING libraries, OFTEN called packages. For example, the JavaScript ecosystem has NPM (Node PACKAGE Manager), where developers can find and use libraries written by other JavaScript developers.

NuGet is a package manager for the .NET ecosystem. Microsoft developed it to provide access to thousands of packages written by .NET developers. You can also use it to share the code you wrote with others.

A TYPICAL web application developed using ASP.NET relies on many open source NuGet packages to FUNCTION. For example, Newtonsoft.Json is a very popular package (with 91,528,205 downloads at the time of writing) used to work with JSON data in .NET. 

9.

What is the purpose of the .csproj file?

Answer»

The PROJECT file is one of the most important files in our application. It tells .NET how to BUILD the project.

All .NET projects list their dependencies in the .csproj file. If you have worked with JavaScript before, think of it like a package.json file. The difference is, instead of a JSON, this is an XML file.

When you run dotnet restore, it uses the .csproj file to figure out which NuGet packages to download and copy to the project folder (check out the next question to learn more about Nuget).

The .csproj file ALSO CONTAINS all the information that .NET tooling needs to build the project. It INCLUDES the type of project you are building (console, web, desktop, etc.), the platform this project targets, and any dependencies on other projects or 3rd party libraries.

Here is an example of a .csproj file that lists the Nuget packages and their specific versions. 

<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup> <TargetFramework>net5.0</TargetFramework></PropertyGroup><ItemGroup> <PackageReference Include="AWSSDK.S3" Version="3.5.6.5" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" /> <PackageReference Include="Npgsql" Version="5.0.1.1" /> <PackageReference Include="Serilog" Version="2.10.0" /></ItemGroup></Project>

In the above example, 

  • The SDK attribute specifies the type of .NET project.
  • TargetFramework is the framework this application will run on, .NET 5 in this case.
  • The PackageReference element includes the NuGet packages. The Version attribute specifies a version of the package we want.
10.

Explain the role of the various components of the MVC pattern?

Answer»

Model: Represents all the data and business logic that the user works within a web application. In ASP.NET, the model is represented by C# classes that hold the data and the related logic that operates on that data. The 'Models' directory STORES the model classes.

For example, a model class representing a blog post might look like this:

// Models/Post.csnamespace app.Models{ PUBLIC class Post { public int ID { get; set; } public string Title { get; set; } public string Body { get; set; } }}

View: Represents all the UI logic of the application. In a web application, it represents the HTML that's sent to the user and displayed in the browser.

One important thing to remember is that this HTML is not static or hard-coded. It's generated dynamically by the controller using a model's data. In ASP.NET, the 'Views' directory CONTAINS the views in files ending with the .cshtml file extension.

To continue our example of a blog post, a view to render a post might be:

// Views/Post.cshtml<div class="post"> <div class="title"> <a href="/posts/@post.ID">@post.Title</a> </div> <div class=body> @Html.Raw(post.Body) </div></div>

Controller: ACTS as an interface between Model and View. It processes the business logic and incoming requests, manipulates data using the Model, and interacts with the Views to render the FINAL output.

In ASP.NET, these are C# classes that form the glue between a model and a view. They handle the HTTP request from the browser, then retrieve the model data and pass it to the view to dynamically render a response. The 'Controllers' directory stores the controller classes.

A PostController that builds the view for the post by fetching the Post model will be:

// Controllers/PostControllernamespace app.Controllers{ public class PostsController : BaseController { public IActionResult Post(int id) { // Get the post from the database Post post = _service.Get(id); // Render the post.cshtml view, by providing the post model return View(post); } }}
11.

What is the MVC pattern?

Answer»

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. It’s different to note that this pattern is unrelated to the layered pattern we saw earlier. MVC pattern operates on the software side, while the layered pattern DICTATES how and where we place our DATABASE and application servers.

In an application that follows the MVC pattern, each COMPONENT has its role well specified. For example, model classes only hold the data and the BUSINESS logic. They don't deal with HTTP requests. Views only display information. The controllers handle and respond to user input and decide which model to pass to which view. This is known as the SEPARATION of responsibility. It makes an application easy to develop and maintain over time as it grows in complexity.

Though Model-View-Controller is one of the oldest and most prominent patterns, alternate patterns have emerged over the years. Some popular patterns include MVVM (Model-View-ViewModel), MVP (Model-View-Presenter), MVA (Model-View-Adapter).

12.

What is a web server?

Answer»

The term web server can REFER to both hardware or software, working SEPARATELY or together.

On the hardware side, a web server is a computer with more processing power and memory that stores the application’s back-end code and static assets such as IMAGES and JavaScript, CSS, HTML files. This computer is connected to the INTERNET and allows data flow between connected devices. 

On the software side, a web server is a program that accepts HTTP requests from the clients, such as a web browser, processes the request, and returns a response. The response can be static, i.e. image/text, or dynamic, i.e. calculated total of the shopping cart.

Popular examples of web servers include Apache, Nginx, IIS.

13.

Explain how HTTP protocol works?

Answer»

HYPERTEXT Transfer Protocol (HTTP) is an application-layer protocol for transmitting HYPERMEDIA documents, such as HTML. It handles COMMUNICATION between web browsers and web servers. HTTP follows a classical client-server model. A client, such as a web browser, opens a connection to make a request, then waits until it receives a response from the server.

HTTP is a protocol that allows the fetching of resources, such as HTML documents. It is the foundation of any data exchange on the Web, and it is a client-server protocol, which MEANS requests are initiated by the RECIPIENT, usually the Web browser. 

14.

When do you choose classic ASP.NET over ASP.NET Core?

Answer»

Though it’s a better CHOICE in almost all the aspects, you don’t have to switch to ASP.NET Core if you are maintaining a legacy ASP.NET application that you are happy with and that is no longer actively developed.
ASP.NET MVC is a better choice if you:

  • Don’t need cross-platform support for your Web app.
  • Need a stable environment to work in.
  • Have NEARER release schedules.
  • Are ALREADY working on an EXISTING app and EXTENDING its functionality.
  • Already have an existing team with ASP.NET expertise.
15.

What are some benefits of ASP.NET Core over the classic ASP.NET?

Answer»
  • Cross-Platform: The main advantage of ASP.NET Core is that it’s not tied to a Windows operating system, like the legacy ASP.NET FRAMEWORK. You can develop and run production-ready ASP.NET Core apps on Linux or a Mac. Choosing an open-source operating system like Linux results in significant cost-savings as you don’t have to pay for Windows licenses. 
  • High PERFORMANCE: It’s also designed from scratch, keeping performance in mind. It’s now one of the fastest WEB application frameworks. 
  • Open Source: Finally, it’s open-source and actively contributed by thousands of developers all over the world. All the source code is hosted on GitHub for anyone to see, change and contribute back. It has resulted in significant goodwill and trust for Microsoft, notwithstanding the patches and bug-fixes and improvements added to the framework by contributors worldwide. 
  • New TECHNOLOGIES: With ASP.NET Core, you can develop applications using new technologies such as Razor Pages and Blazor, in addition to the traditional Model-View-Controller approach. 
16.

What is a web application framework, and what are its benefits?

Answer»

Learning to build a modern WEB application can be daunting. Most of the web applications have a standard set of functionality such as:

  • Build a dynamic response that corresponds to an HTTP request.
  • Allow users to log into the application and manage their data.
  • Store the data in the DATABASE.
  • Handle database connections and transactions. 
  • Route URLS to appropriate methods.
  • Supporting sessions, cookies, and user authorization.
  • Format output (e.g. HTML, JSON, XML), and improve security.

Frameworks help developers to write, maintain and scale applications. They provide tools and libraries that simplify the above RECURRING TASKS, eliminating a lot of unnecessary complexity. 

17.

What is a web application?

Answer»

A WEB application is a software that the users can access through a web browser such as Chrome or Firefox. The browser MAKES an HTTP request for a specific URL for the web application. The web application server intercepts and processes the request to build a dynamic HTML response sent to the user. Some examples of popular web applications include StackOverflow, Reddit, GOOGLE, etc.

A web application is different from a typical website. A website is static. When you go to the website, it returns an HTML page without doing any processing to build the contents of that HTML page. You will see the same page if you reload the browser. In contrast, a web application might return a different response each TIME you VISIT.

For example, let’s say you ask a question on Stack Overflow. Initially, you will see only your question when you visit the URL. However, if another user answers your question, the browser will display that answer on your next visit to the same URL.

A web application consists of multiple separate layers. The typical example is a three-layered architecture made up of presentation, business, and data layers. For example, the browser (presentation) talks to the application server, which communicates to the database server to fetch the requested data.

The following figure illustrates a typical Web application architecture with standard components grouped by different areas of concern.

Previous Next