Total Page Preview:   000000000225

What is Middleware in Asp.Net Core MVC in English and Hindi

Middleware in English

Middleware in ASP.NET Core MVC refers to components or modules that sit between the server and the application's main logic, processing requests and responses. They provide functionalities like logging, authentication, routing, and more. Each middleware component can perform specific tasks during the request/response lifecycle, creating a chain of processing steps.

Middleware is a piece of code in an application pipeline used to handle requests and responses.

For example, we may have a middleware component to authenticate a user, another piece of middleware to handle errors, and another middleware to serve static files such as JavaScript files, CSS files, images, etc.
Middleware can be built-in as part of the .NET Core framework, added via NuGet packages, or can be custom middleware. These middleware components are configured as part of the application startup class in the configure method. Configure methods set up a request processing pipeline for an ASP.NET Core application. It consists of a sequence of request delegates called one
after the other.
The following figure illustrates how a request process through middleware components.
Generally, each middleware may handle the incoming requests and passes execution to the next middleware for further processing.
But a middleware component can decide not to call the next piece of middleware in the pipeline. This is called short-circuiting or terminate the request pipeline. Short-circuiting is often desirable because it avoids unnecessary work. For example, if the request is for a static file like an image CSS file JavaScript file etc., these static files middleware can handle and serve that request and then short-circuit the rest of the pipeline.
 
Let’s create an ASP.NET Core Web application and observe the default configuration of middleware in the Configure method of the Startup class.

 

Middleware in Hindi

Middleware, ASP.NET Core MVC me, ek tarah ka software component hota hai jo request aur response ko process karta hai. Yani ki, jab aap apne web application me HTTP request receive karte hai, to middleware is request ko process karta hai, aur phir response ko generate karta hai. Ye response fir agle middleware ya client browser tak pahunchta hai.

Har middleware ka ek specific task hota hai, jaise request processing, response generation, error handling, authentication, logging, caching, etc. Middleware ka chain bana kar request pipeline taiyar hota hai, jisse incoming request ko process karte waqt wo kuch specific tasks ko karte hain.
Jab aap apne ASP.NET Core MVC application me middleware ka use karte hain, to aap apne application ke behavior ko customize kar sakte hain. Ye aapko flexibility deta hai ki aap kis tarah se request ko process karna chahte hain, aur kis tarah se response ko generate karna chahte hain.
Middleware ke use se aap application ke components ko modular tarike se manage kar sakte hain, jisse code maintain karne aur development me aasani ho.
 
 
 
 
 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: