ASP.NET review
What is caching?
Caching is the process of storing data in a temporary storage location that is quicker to access than original location of the data. Caching improves the scalability and performance of your application.
The Model (In MVC)
Represents all the data and business logic that user works within a web application.
Explain how Convention Routing works?
Conventional routing uses predefined conventions to match the incoming HTTP request to a controller's action method. Convention Routing approaches the routing problem general-case-first; by default, you are given a route that will probably match most if not all of your routes, and are asked to define if there are any more specific routes you would also like to handle.
Explain the concept of middleware in ASP.NET
Middleware is the plumbing software that facilitates communication flow between two components.
What is the MVC Pattern?
The Model-View-Controller(MVC) is an architectural pattern that separates an application into three main logical components: the model, view, and the controller. MVC pattern operates on the software side, while the layered pattern dictates how and where we place our database and application servers.
The benefits of ASP.NET Core over classic ASP.NET?
- Cross-Platform: Main advantage of ASP.NET Core isn't tied to windows operating system like legacy ASP.NET framework. You can use it on Linux or Mac. - High Performance: Designed from scratch, It's the fastest web application frameworks - Open Source: It's-open source and contributed by thousands of developers all over the world. - New Technologies: ASP.NET Core, you can develop applications using new technologies such as Razor Pages and Blaxor, in addition to the traditional MVC.
What is a cookie?
A cookie is a small amount of data persisted across requests and sessions. They store information about the user. The browser stores the cookies on the user's computer (usually as key-value pairs)
What is a web server?
A web server can refer to both hardware or software, working separately or together. Hardware: 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 JS, CSS, HTML. This PC is connected to the internet and allows data flow between connected devices. Software: A web server is a program that accepts HTTP requests from the clients, such as a web browser, processes the request, and return a response. The response can be static, image/text, or dynamic.
What's the difference between a web application and website?
A website is static, when you go to the website, it returns a HTML page without doing any processing to build the contents of that HTML page.
What are the different types that implement the IActionResult interface?
ASP.NET Core has many different types of IActionResult: - ViewResult - RedirectResult - RedirectToRouteResult - FileResult - ContentResult - StatusCodeResult - NotFoundResult
Explain how dependency injection works in ASP.NET Core?
ASP.NET Core injects instances of dependency classes by using the built-in IoC (Inversion-of-Control) container.
Controller (In MVC)
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.
What is an Action Method?
An action method is a method in a controller class with the following restrictions: 1- Must be public 2- It cannot be overloaded 3- It cannot be a static method An action method executes an action in response to an HTTP request.
What is the purpose of the appsettings.json file?
Appsettings.json contains all of the application's settings, allow you to configure your application behavior.
Explain how Attribute-based Routing works?
Attribute routing is an alternative routing strategy for conventional routing. It's often used to create REST API endpoints for web services. Attribute Routing (introduced in MVC 5) is the ability to add routes to the Route Table via attributes so that the route definitions are in close proximity to their corresponding actions.
What is dependency injection?
Dependency injection is a design pattern that helps to develop loosely coupled code. Dependency injection means providing the objects that an object needs (its dependencies) in that object's constructor instead of requiring the object to construct them. It reduces and eliminates unnecessary dependencies between objects that don't need to know each other. It helps in testing, mocking, or stubbing out the dependencies at runtime.
What is Entity Framework?
Entity Framework is a library that provides an object-orientated way to access a database. It acts as an object-relational mapper, communicates with the database, and maps database responses to .NET classes and objects.
What's the HTTPContext object? How can you access it within a Controller?
HTTPContext encapsulates all HTTP-specific information about an individual HTTP request.
Explain how HTTP protocol works?
Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It allows fetching of resources such as HTML documents. It handles communication between web browsers and web servers. HTTP follows a classical client-server model. A client (ex.) web browser) opens a connection to make a request, then waits until it receives a response from the server.
What is IIS?
IIS stands for Internet Information Services.
What is the purpose of the .csproj file?
It's one of the most important files in our application. It tells .NET how to build the project. It's similar to Javascript like package.json file. All .NET projects list their dependencies in the .csproj file. The .csproj file 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.
What is NuGet package manager?
Javascript ecosystem has NPM (Node Package Manager), the NuGet is a package manager for the .NET ecosystem. It provides access to thousands of packages written by .NET developers. Open source NuGet packages to function. Newtonsoft.Json is a very popular package used to work with JSON data in .NET
What is Kestrel?
Kestral is an open-source, cross-platform web server designed for ASP.NET Core.
What is model binding in ASP.NET?
Model binding system fetches data from multiple sources such as form fields, route data, and query strings. It provides data to controllers and views in method parameters and properties, converting plain string data to .NET objects and types in the process.
What is a web application framework, and what are its benefits?
Most web applications have standard set of functionality such as: Build 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.
What is the purpose of the Program class?
Program.cs class is the entry point of our application. An ASP.NET application starts in the same way as a console applic
What is RESTful Web Service or Web API?
RESTful protocol uses verbs like GET,POST,PUT,DELETE to communicate between multiple applications. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. REST has been employed throughout the software industry and is a widely accepted set of guidelines for creating stateless, reliable web APIs. A web API that obeys the REST constraints is informally described as RESTful. RESTful web APIs are typically loosely based on HTTP methods to access resources via URL-encoded parameters and the use of JSON or XML to transmit data.
The View (In MVC)
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.
What is routing, and how can you define routes in ASP.NET Core?
Routing is the process of mapping an incoming HTTP request to a specific method in the application code. A router maps the incoming requests to the route handler. It takes in the URL as an input, deconstructs it to determine the controller and action method to route the request. Ex.) /posts/show URL maps to the Show action method on the PostsController. Two ways to define routes: - Conventional Routing - Attribute-Based Routing
What is the difference between IIS and Kestrel? Why do we need two web servers?
The main difference between IIS and Kestrel is that Kestral is cross-platform server. It runs on Windows, Linux, and Mac, whereas IIS only runs on Windows.
What is the purpose of the wwwroot folder?
The wwwroot folder contains static files and compiled assets, such as JS, CSS, and images. WWwroot is the only folder in the entire project that's exposed as-is to the browser.
What is the purpose of the Startup class?
This class handles two important aspects of your application, namely service registration, and middleware pipleline.
What is a web application?
Web application is a software that 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. A web application consists of multiple separate layers. The typical example is a three-layer architecture made up of presentation, business, and data layers. The browser(presentation) talks to the application server, which communicates to the data server to fetch the requested data.
When do you choose classic ASP.NET over ASP.NET Core?
You don't have to switch to ASP.NET Core if you're maintaining a legacy ASP.NET application that you are happy with and that is no longer actively developed. - 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