---
title: "The ASP .NET Core Pipeline Order Nobody Explains Properly"
url: https://daily.dev/posts/the-asp-net-core-pipeline-order-nobody-explains-properly-4qy8txaca
source_url: https://mwaseemzakir.substack.com/p/the-asp-net-core-pipeline-order-nobody
type: article
source: "Waseem .NET Newsletter"
published: 2026-08-15T04:09:00.969Z
updated: 2026-08-15T04:09:26.685Z
tags: ["authentication", "c#", "aspnet"]
reading_time: 8
upvotes: 10
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The ASP .NET Core Pipeline Order Nobody Explains Properly

**[Waseem .NET Newsletter](https://daily.dev/sources/mwaseemzakir)** · 8 min read · 10 upvotes · 0 comments

## Summary

A deep dive into the ASP.NET Core middleware pipeline explaining how requests flow through Use, Run, and Map, why order matters (especially authentication before authorization), how short-circuiting works, the difference between UseWhen and MapWhen, and when to choose middleware versus filters. Includes code examples for inline, convention-based, and factory-based (IMiddleware) custom middleware.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://mwaseemzakir.substack.com/p/the-asp-net-core-pipeline-order-nobody>

## Questions this post answers

### What happens if I call app.UseAuthorization before app.UseAuthentication in ASP.NET Core?

Authorization runs before the user's identity is established, which produces broken access-control behavior that looks unrelated to middleware order. Authentication determines who the user is; authorization decides what that identified user can access, so authentication middleware must be registered first for authorization to work correctly.

_Anyone debugging odd auth failures in ASP.NET Core can compare setups like this on daily.dev before assuming it's a code bug._

### What is the difference between app.Use, app.Run, and app.Map in ASP.NET Core?

Use adds middleware that can pass control to the next component via a next delegate, Run adds terminal middleware with no next delegate so processing ends there, and Map creates a separate branch of the pipeline based on the request path, stripping the matched segment from Request.Path into Request.PathBase.

_daily.dev helps developers comparing ASP.NET Core pipeline building blocks find grounded explanations fast._

### What is the difference between UseWhen and MapWhen in ASP.NET Core?

UseWhen branches on any condition (not just path) and rejoins the main pipeline afterward unless something inside short-circuits, while MapWhen also branches on any condition but behaves like Map, meaning the branch never rejoins the main pipeline. Map is the only one restricted to branching purely on the request path.

_Developers structuring conditional ASP.NET Core pipelines can dig into distinctions like this on daily.dev._

## Similar posts on daily.dev

- [ASP.NET Core Middleware: Building and Using the Request Pipeline](https://daily.dev/posts/asp-net-core-middleware-building-and-using-the-request-pipeline-tav1b2ck7) · We Are .NET · 1 upvotes · 0 comments
- [ASP.NET Core 11 Request Pipeline Performance Deep Dive](https://daily.dev/posts/asp-net-core-11-request-pipeline-performance-deep-dive-y8dxv0kx8) · C\# Corner · 2 upvotes · 0 comments

---

Tags: [#authentication](https://daily.dev/tags/authentication), [#c#](https://daily.dev/tags/c#), [#aspnet](https://daily.dev/tags/aspnet)

[View this post on daily.dev](https://daily.dev/posts/the-asp-net-core-pipeline-order-nobody-explains-properly-4qy8txaca)
