<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu" -->

---
title: Decorator Design Pattern in ASP.NET Core | daily.dev
description: Explains the Decorator design pattern as a way to add behavior, such as logging, to existing services without modifying their code. Walks through a C# example...
canonical: https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Decorator Design Pattern in ASP.NET Core | daily.dev
og:description: Explains the Decorator design pattern as a way to add behavior, such as logging, to existing services without modifying their code. Walks through a C# example...
og:url: https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu
og:image: https://api.daily.dev/og/posts/njvwgGetu.png
og:image:alt: Decorator Design Pattern in ASP.NET Core
og:image:width: 1200
og:image:height: 630
og:locale: 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.

# Decorator Design Pattern in ASP.NET Core

**[NikolaTech](https://daily.dev/sources/nikolatech)** · 3 min read · 0 upvotes · 0 comments

## Summary

Explains the Decorator design pattern as a way to add behavior, such as logging, to existing services without modifying their code. Walks through a C# example wrapping an IWeatherService implementation with a LoggingWeatherServiceDecorator, shows two manual dependency injection registration approaches in ASP.NET Core, and demonstrates simplifying the setup with the open source Scrutor library's Decorate extension method.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nikolatech.net/blogs/decorator-pattern-aspnetcore>

## Questions this post answers

### How do I register a decorator for a service in ASP.NET Core dependency injection without using a third-party library?

Register the concrete service type directly, then register the interface with a factory delegate that manually constructs the decorator, injecting the concrete service and any decorator dependencies like a logger. For example, register WeatherService on its own, then register IWeatherService using a lambda that resolves WeatherService and ILogger, and returns a new LoggingWeatherServiceDecorator wrapping them.

_daily.dev surfaces patterns like this for developers wiring up decorators in their own DI containers._

### What does the Scrutor library's Decorate method do for ASP.NET Core service registration?

Scrutor's Decorate extension method, added to IServiceCollection, wraps an already registered service implementation with a decorator class in a single line, replacing manual factory-based registration. For example, after registering IWeatherService with WeatherService, calling Decorate<IWeatherService, LoggingWeatherServiceDecorator>() applies the decorator automatically, simplifying setup especially when stacking multiple decorators.

_Developers comparing manual DI wiring against libraries like Scrutor can find similar comparisons on daily.dev._

## Similar posts on daily.dev

- [Decorator Pattern Best Practices in C\#: Code Organization and Maintainability](https://daily.dev/posts/decorator-pattern-best-practices-in-c-code-organization-and-maintainability-9r8qfs3dy) · We Are .NET · 0 upvotes · 0 comments
- [When to Use Decorator Pattern in C\#: Decision Guide with Examples](https://daily.dev/posts/when-to-use-decorator-pattern-in-c-decision-guide-with-examples-b2qjj3xi5) · We Are .NET · 1 upvotes · 0 comments
- [Proxy vs Decorator Pattern in C\#: Key Differences Explained](https://daily.dev/posts/proxy-vs-decorator-pattern-in-c-key-differences-explained-a6e4atoz8) · We Are .NET · 1 upvotes · 0 comments
- [Implementing the Sidecar Pattern in Microservices-based ASP.NET Core Applications](https://daily.dev/posts/implementing-the-sidecar-pattern-in-microservices-based-asp-net-core-applications-k8vqpcg1q) · InfoQ · 0 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Decorator Design Pattern in ASP.NET Core","url":"https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu"},"datePublished":"2026-10-04T13:05:52.056Z","dateModified":"2026-10-04T13:12:19.173Z","description":"Explains the Decorator design pattern as a way to add behavior, such as logging, to existing services without modifying their code. Walks through a C# example...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/505d0093cc76ba818198a835f471f3d3?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/505d0093cc76ba818198a835f471f3d3?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"NikolaTech","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"NikolaTech","logo":"https://media.daily.dev/image/upload/s--1h2fO6FL--/f_auto,q_auto/v1791119050/logos/nikolatech?_a=BAMAMicg0","url":"https://daily.dev/sources/nikolatech"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c#,aspnet,dependency-injection","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"NikolaTech","item":"https://daily.dev/sources/nikolatech"},{"@type":"ListItem","position":3,"name":"Decorator Design Pattern in ASP.NET Core"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/decorator-design-pattern-in-asp-net-core-njvwggetu#faq","mainEntity":[{"@type":"Question","name":"How do I register a decorator for a service in ASP.NET Core dependency injection without using a third-party library?","acceptedAnswer":{"@type":"Answer","text":"Register the concrete service type directly, then register the interface with a factory delegate that manually constructs the decorator, injecting the concrete service and any decorator dependencies like a logger. For example, register WeatherService on its own, then register IWeatherService using a lambda that resolves WeatherService and ILogger, and returns a new LoggingWeatherServiceDecorator wrapping them. daily.dev surfaces patterns like this for developers wiring up decorators in their own DI containers."}},{"@type":"Question","name":"What does the Scrutor library's Decorate method do for ASP.NET Core service registration?","acceptedAnswer":{"@type":"Answer","text":"Scrutor's Decorate extension method, added to IServiceCollection, wraps an already registered service implementation with a decorator class in a single line, replacing manual factory-based registration. For example, after registering IWeatherService with WeatherService, calling Decorate<IWeatherService, LoggingWeatherServiceDecorator>() applies the decorator automatically, simplifying setup especially when stacking multiple decorators. Developers comparing manual DI wiring against libraries like Scrutor can find similar comparisons on daily.dev."}}]}
```

