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
-
Economics & Finance
Articles by Nizamuddin Siddiqui
Page 22 of 196
How do we specify MIME type in Asp.Net WebAPI C#?
A media type, also called a MIME type, identifies the format of a piece of data. In HTTP, media types describe the format of the message body. A media type consists of two strings, a type and a subtype. For example − text/html image/png application/json When an HTTP message contains an entity-body, the Content-Type header specifies the format of the message body. This tells the receiver how to parse the contents of the message body. When the client sends a request message, it can include an Accept header. The Accept header tells the server which ...
Read MoreHow to run an external application through a C# application?
An external application can be run from a C# application using the Process class. A process is a program that is running on your computer. This can be anything from a small background task, such as a spell-checker or system events handler, to a full-blown application like Notepad. Each process provides the resources needed to execute a program and is started with a single thread, known as the primary thread. Processes are heavily dependent on system resources, while threads require minimal resources. The Process class is present in the System.Diagnostics namespace. Syntax Following is the basic syntax ...
Read MoreWhat is the use of the Configure() method of startup class in C# Asp.net Core?
The Configure() method in ASP.NET Core's Startup class is used to define the application's request pipeline. This method configures how the application handles incoming HTTP requests and outgoing responses using middleware components. The Configure() method is called at runtime after the ConfigureServices() method. It receives an IApplicationBuilder instance from the built-in IoC container, which is used to add middleware to the request pipeline. Syntax Following is the basic syntax of the Configure() method − public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // Configure middleware pipeline } Parameters The ...
Read MoreWhat is the use of "Map" extension while adding middleware to C# ASP.NET Core pipeline?
The Map extension method in ASP.NET Core is used for conditional middleware execution based on the request path. It allows you to branch the middleware pipeline and execute different middleware components for specific URL paths, creating a more organized and efficient request handling system. Middleware components are assembled into an application pipeline to handle requests and responses. Each component can choose whether to pass the request to the next component and perform actions before and after the next component is invoked. Syntax Following is the syntax for using the Map extension method − app.Map("/path", appBuilder ...
Read MoreWhat is the difference between IApplicationBuilder.Use() and IApplicationBuilder.Run() C# Asp.net Core?
We can configure middleware in the Configure method of the Startup class using IApplicationBuilder instance. The two primary methods for adding middleware are Run() and Use(), each serving different purposes in the middleware pipeline. Run() is an extension method that adds a terminal middleware to the application's request pipeline, meaning it terminates the pipeline and does not call the next middleware. Use() allows middleware to pass control to the next component in the pipeline. Syntax Following is the syntax for the Run() method − public static void Run(this IApplicationBuilder app, RequestDelegate handler) Following ...
Read MoreHow to enable Session in C# ASP.NET Core?
Session is a server-side storage feature in ASP.NET Core that enables you to store user data temporarily across multiple requests. Session data is stored in a dictionary on the server, with each user session identified by a unique SessionId. The SessionId is stored as a cookie on the client side and sent with every request to maintain the connection between the client and their session data. This cookie is browser-specific and cannot be shared between different browsers. While SessionId cookies persist only for the browser session, the actual session data on the server has a configurable timeout (default: 20 ...
Read MoreHow can we inject the service dependency into the controller C# Asp.net Core?
ASP.NET Core uses a built-in Inversion of Control (IoC) container to inject dependencies into controllers and other services. This container, represented by the IServiceProvider implementation, supports constructor injection by default and manages application services throughout their lifecycle. To use dependency injection in controllers, you must first register your services with the IoC container in the ConfigureServices method of the Startup class or Program.cs file. Syntax Following is the syntax for registering services in the IoC container − services.AddSingleton(); services.AddScoped(); services.AddTransient(); Following is the syntax for constructor injection in a controller − ...
Read MoreHow to specify service lifetime for register service that added as a dependency C# Asp.net Core?
The built-in IoC container in ASP.NET Core manages the lifetime of registered services and automatically disposes service instances based on the specified lifetime. Understanding service lifetimes is crucial for proper dependency injection and resource management. The built-in IoC container supports three kinds of lifetimes − Singleton − IoC container will create and share a single instance of a service throughout the application's lifetime. Transient − The IoC container will create a new instance of the specified service type every time you ask for it. Scoped − IoC container will create an instance of the specified service type ...
Read MoreHow C# ASP.NET Core Middleware is different from HttpModule?
In ASP.NET Core, middleware replaces the traditional HttpModules used in classic ASP.NET. While both serve as components that handle HTTP requests and responses, they differ significantly in configuration, execution control, and architecture. Key Differences Overview HttpModules are event-driven components tied to the ASP.NET application lifecycle, while middleware components form a pipeline where each component can handle requests before passing them to the next component in the chain. HttpModules vs Middleware Architecture HttpModules (Classic ASP.NET) Event-driven execution Fixed lifecycle ...
Read MoreWhat is Kestral C# Asp.net Core?
Kestrel is a cross-platform web server for ASP.NET Core. It is included by default in ASP.NET Core applications and is supported on all platforms where .NET Core runs. Kestrel serves as the primary HTTP server for ASP.NET Core applications and can be configured to work either as a standalone edge server or in combination with reverse proxy servers like IIS, Nginx, or Apache. Key Features Cross-platform: Runs on Windows, macOS, and Linux. Lightweight: Minimal overhead and high performance. HTTP/HTTPS support: Handles both HTTP and HTTPS protocols. Async/await support: Built ...
Read More