<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Usman Pervez</title>
    <description>The latest articles on DEV Community by Usman Pervez (@usman_1e2caa0a5f6b5c8d99b).</description>
    <link>https://dev.to/usman_1e2caa0a5f6b5c8d99b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3834863%2Fc28e875e-35d8-4c5e-9aca-c9eee19f8ceb.jpg</url>
      <title>DEV Community: Usman Pervez</title>
      <link>https://dev.to/usman_1e2caa0a5f6b5c8d99b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/usman_1e2caa0a5f6b5c8d99b"/>
    <language>en</language>
    <item>
      <title>What is Request Pipeline?</title>
      <dc:creator>Usman Pervez</dc:creator>
      <pubDate>Fri, 20 Mar 2026 07:42:26 +0000</pubDate>
      <link>https://dev.to/usman_1e2caa0a5f6b5c8d99b/what-is-request-pipeline-2com</link>
      <guid>https://dev.to/usman_1e2caa0a5f6b5c8d99b/what-is-request-pipeline-2com</guid>
      <description>&lt;p&gt;The request pipeline is simply:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The path an HTTP request follows inside ASP.NET Core before a response is returned.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think of it like a chain of steps.&lt;/p&gt;

&lt;p&gt;When a user sends a request like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://yourwebsite.com/api/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;that request does NOT directly go to the controller.&lt;/p&gt;

&lt;p&gt;Instead, it passes through multiple stages first.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How the pipeline actually works&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine this flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Server → Middleware 1 → Middleware 2 → Middleware 3 → Controller → Response → Back through middleware → Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So every request must pass through middleware before reaching the controller.&lt;/p&gt;

&lt;p&gt;And every response passes back through the same pipeline.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real example of what happens internally
&lt;/h2&gt;

&lt;p&gt;When someone opens your API endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /api/users
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ASP.NET Core processes it like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Request reaches the server&lt;/li&gt;
&lt;li&gt;Authentication middleware checks if the user is logged in&lt;/li&gt;
&lt;li&gt;Authorization middleware checks if the user has permission&lt;/li&gt;
&lt;li&gt;Routing middleware finds which controller should handle the request&lt;/li&gt;
&lt;li&gt;Controller executes the logic&lt;/li&gt;
&lt;li&gt;Response is created&lt;/li&gt;
&lt;li&gt;Response travels back through middleware&lt;/li&gt;
&lt;li&gt;Response is sent to the browser&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This entire flow is called the &lt;strong&gt;request pipeline&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Most fresh developers think:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User → Controller → Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But real flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User → Middleware → Routing → Controller → Middleware → Response

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What is Middleware (the core of the pipeline)
&lt;/h2&gt;

&lt;p&gt;Middleware is a small piece of code that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receives a request&lt;/li&gt;
&lt;li&gt;Can process it&lt;/li&gt;
&lt;li&gt;Can stop it&lt;/li&gt;
&lt;li&gt;Can modify it&lt;/li&gt;
&lt;li&gt;Or pass it to the next step&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Authentication middleware:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If token is valid → continue&lt;/li&gt;
&lt;li&gt;If token is invalid → stop the request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So middleware controls the entire request flow.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where the pipeline is written in a .NET project
&lt;/h2&gt;

&lt;p&gt;Open this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see lines like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseAuthentication&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseAuthorization&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapControllers&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These lines define the &lt;strong&gt;order of the request pipeline.&lt;/strong&gt;&lt;br&gt;
And the order is extremely important.&lt;/p&gt;




&lt;p&gt;I Hope you get the concept, Thank You.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>dotnetcore</category>
      <category>requestpipelineindotnet</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
