Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Akshay Khot
Page 2 of 3
Explain the purpose of the Startup class in ASP.NET Core
The Startup class configures your application's services and defines the middleware pipeline.Generally speaking, the Program class is where you configure your application's infrastructure, such as the HTTP server, integration with IIS, and configuration sources. In contrast, the Startup class defines which components and features your application uses and the middleware pipeline for your app.Startup.csHere is a sample Startup.cs file in a standard ASP.NET Core application.using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace TutorialsPoint{ public class Startup{ public Startup(IConfiguration configuration){ ...
Read MoreExplain the purpose of the Program class in ASP.NET Core
An ASP.NET Core application starts similarly to a .NET Console application. It uses the Main() method defined in the Program.cs file as the entry point of the application. The framework calls the Main() method whenever you start the web application.In the ASP.NET Core application, the Main() method builds and runs the Host. The Host object is one of the essential parts of the ASP.NET Core application. It contains the configuration and the webserver (Kestrel) that your application uses.Program.csHere is a sample Program.cs file in a standard ASP.NET Core application.using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; ...
Read MoreExplain the purpose of the .csproj file in an ASP.NET application
The .csproj file tells dotnet how to build the ASP.NET application. It’s one of the most important files in an ASP.NET project.An ASP.NET project can depend on third-party libraries developed by other developers. Usually, these libraries are installed as Nuget packages using Nuget package manager. Once you install a package using Nuget, the name of the package along with its version is listed in the .csproj file.If you are familiar with Node.js, you can think of a .csproj file as a package.json file. Upon running the ‘dotnet restore’ command, dotnet uses the .csproj file to determine the packages to install ...
Read MoreWhat are the benefits of choosing ASP.NET Core over ASP.NET?
ASP.NET Core is a high-performance, cross-platform, and open-source framework. It allows you to build modern, cloud-enabled, and Internet-connected apps.With ASP.NET Core, you can:Build web applications and services, Internet of Things (IoT) apps, and backends for mobile applications.Work on your favorite operating system such as Windows, macOS, or Linux, and choose the tools and IDEs of your choice.Develop on and Deploy to the cloud or on-premises.Take advantage of containers and Docker to ease the deployment and distribution of your application.Run on the modern, fast, lightweight .NET Core framework.Some of the significant benefits of the ASP.NET Core framework over the ASP.NET framework ...
Read MoreExplain how logging works in ASP.NET Core
Logging is the process of recording events in software as they happen in real-time, along with other information such as the infrastructure details, time taken to execute, etc. Logging is an essential part of any software application. Having logs is crucial, especially when things go wrong. Logs help you understand the failures or performance bottlenecks and fix the problems.Logs are typically written to a database, console, or file, depending on the severity of the application and convenience. Although it's possible to record any data in the logs, you write informational messages and error messages in general. The informational messages capture ...
Read MoreExplain the role of HttpContext class in ASP.NET Core
The HttpContext encapsulates all the HTTP-specific information about a single HTTP request.When an HTTP request arrives at the server, the server processes the request and builds an HttpContext object. This object represents the request which your application code can use to create the response.The HttpContext object constructed by the ASP.NET Core web server acts as a container for a single request. It stores the request and response information, such as the properties of request, request-related services, and any data to/from the request or errors, if there are any.ASP.NET Core applications access the HTTPContext through the IHttpContextAccessor interface. The HttpContextAccessor class ...
Read MoreHow does ASP.NET Core provide data access with Entity Framework?
Entity Framework is an ORM (object-relational mapper) framework that makes it easy to create, retrieve, update, or delete data from relational databases. Using Entity Framework, you can work with C# objects that abstract the database related code, so you rarely have to deal with raw SQL.The following figure illustrates where the Entity Framework fits into a layered architecture.Entity Framework Core (EF Core) is the new version of Entity Framework 6. Similar to .NET Core, EF Core is a lightweight, open-source, and cross-platform version of Entity Framework. It is developed to be used with .NET Core applications.To integrate EF Core into ...
Read MoreExplain the iterator pattern in .NET
The iterator pattern is used to loop over the elements in a collection and is implemented using the IEnumerator interface. It defines the basic low-level protocol through which elements in a collection are traversed—or enumerated. This is done in a forward-only manner.Here's the IEnumerator interface in C#.public interface IEnumerator{ bool MoveNext(); object Current { get; } void Reset(); }MoveNext advances the current element or "cursor" to the next position, returning false if there are no more elements in the collection.Current returns the element at the current position (usually cast from object to a more specific type). MoveNext ...
Read MoreSystem.Reflection namespace in C#
System.Reflection namespace in C# The System.Reflection namespace in C# contains the types that provide information about assemblies, modules, members, parameters, and other items in the code by examining the metadata. The Assembly class in this namespace represents an assembly. Typically, you can access it using the Assembly property on a Type.An assembly's identity consists of four items −Simple nameVersion from the AssemblyVersion attribute in the major.minor.build.revision format (0.0.0.0 if absent)Culture (neutral if not a satellite)Public key token (null if not strongly named)A fuller qualified assembly name is a string, and it includes these identifying items in the format −simple-name, Version=version, ...
Read MoreExplain how the assemblies and DLLs work in .NET
Assembly contains all the compiled types in your application along with their Intermediate Language (IL) code. It is also the basic unit of deployment in .NET. In the latest versions of .NET, i.e. .NET Core, an assembly is a file with a .dll extension, which stands for Dynamic Link Library.There are primarily four items in an assembly.Compiled TypesThe compiled IL code for all the types in your application.Assembly ManifestContains the metadata needed by the Common Language Runtime, such as the dependencies and versions that this DLL references.Its purpose is to describe the assembly to the runtime via the assembly's data, ...
Read More