Business Network California
Products and Services:4,141
Articles and publications:1,588 (+1)
Tenders & Vacancies:499

What is Middleware in ASP. NET Core And How Does It Work?
Information is out of date

What is Middleware in ASP. NET Core And How Does It Work?
Middleware is one of the most important layers in ASP. NET Core, taking software development to next level. In this article, know more about . NET Middleware and How does it work.

Want an absolute control over the request/response action of your application?

Middleware- the catalyst behind the soaring popularity of ASP.NET Core, can help you with this, allowing you to control each request and response activity of your application and making the software architecture comprehensible and meaningful.

So, what exactly is the Middleware?

Middleware, also termed as a software glue, is computer software that allows the applications/software to interact with the database, servers, remote systems, etc, depending on the type used. Middleware makes the communication within the application easier, controlling the HTTP requests and responses.

Before its introduction, the request and response objects in the ASP.NET projects, used to be very big as well as extremely tightly coupled with the web server software i.e.  Internet Information Services(IIS), making the objects difficult to handle. To solve this ASP.NET Core Middleware came into the picture, which showed the way to remove the dependency of the web applications on the server.

How does Middleware Works?

To use the middleware in the application, you need to build the request pipeline using the request delegates, which handles the HTTP request. You can configure the request delegates through the ‘Run’, ‘Map’, and ‘Use’ method on IApplicationBuilder.

These delegates decide whether the request should be passed to the next component in the application pipeline or not. Along with this, it can also perform the required actions such as saving data, before and after the invocation of the next component in the application pipeline. Then the response comes back in the same fashion through the pipeline.

  • Run method

    The Run method is an extension method that handles the requests, accepting the RequestDelegate parameter. The Run() method should be placed at the end of the pipeline as the method terminates the chain, preventing any other middleware to execute.

    app.Run(async context =>
    await context.Response.WriteAsync("Hello from " + _environment);
  • Use method

    The Use() method enables you to perform the action before and after the next middleware delegate. You can also call the required middleware delegate using the function next.Invoke(). It helps include the short-circuiting in the pipeline – a process in which the middleware, instead of passing a task to another middleware, executes it.

    app.Use(async (context, next) =>
    await context.Response.WriteAsync("Hello from " + _environment);
    await next.Invoke(); // invoking the next middleware
  • Map method

    The Map() method checks the path requested by the user and matches it with the path present in the parameter, finding the match the method runs the middleware. It also creates multiple paths and hence the terminating ends for the pipeline.

    How does Middleware Works

You can use multiple Middleware in the ASP.NET Core based web application as per the requirement, some are inbuilt within the frameworks and some of them you need to add through NuGet.

ASP. NET provides following built-in middleware components:

Middleware Description


Provides support for authentication in website and application


Provides support for user sessions management.


Provides support for requested routes.


Provides Cross-Origin Resource Sharing configuration.

Static Files

Provides support for fetching and retrieving static files

How to set up a Middleware Pipeline in your Website?

view all (31)

Other articles and publications:

We wIll learn in this article about What is ASP. NET Core and the Advantages of using ASP. NET Core? Here are the Top 5 Advantages of . NET Core.
ASP. NET Core offers authentication in Single Page Apps (SPAs) using the support for API authorization. Here is the guide on it.
This article explains, how Shopify will work for Small Businesses, Sellers, and Merchants in this pandemic.
Facebook announces partnership with eCommerce platforms. Learn more about What is Facebook shops and its integrations with eCommerce.
Google Shopping; It’s now free to sell on Google. Here’s how this change benefits to retailers, shoppers, and advertisers.
Google announced partnerships with three major eCommerce platforms - Woocommerce, Shopify, BigCommerce. Here's how you can get the benefit.

Articles and publications of other companies:

How to Make Money from Blogging How to Make Money from Blogging
Information may not be reliable
Blogging is one of the easiest ways to make money online. Unfortunately, I see too many people focused on SEO and ranks and not enough on what pays the bills – sharing!
React Native, powered by Facebook, is one of the frameworks for developing cross-platform mobile applications. This framework uses JSX with JavaScript, and it comprises more features.
Software Services and Solutions by GIIT Solutions Software Services and Solutions by GIIT Solutions
Information has not been updated for a long time
GIIT is a software company which provide various software services like DevOps, cyber security services, Data analytics, Machine Learning, IoT, Software training, Development and Testing etc.
Quality Web Designer in San Jose
Information may not be reliable
Webati is the right place where you can build your brand and take it to the top level. We ensure that our work will help you to get more and more followers.
San Jose Graphic Designer has the ability to complete your business webpage requirements. It has great and creative designers that make a good impression in front of visitors of your website.
Here are a few reasons why one should integrate Dynamics CRM with Dynamics GP to improve the overall workflow process in an effective manner.
Business details
  • +1 (323) 455-4591
  • 21900 Burbank Blvd., 3rd Floor, Woodland Hills
The most Agile Technology Company for Web / Mobile Application Development, Web Development, Product Engineering, and Platform Migration.