Overriding externally set headers and HTTP status codes in ASP.NET Core
I was working on an interesting issue in an ASP.NET Core recently. An external framework was responsible for creating an HTTP Response, and I was only in control of a little component that customized some internal behaviours (via a relevant extensibility point), without being able to influence the final response sent over HTTP.
This is common if you think about extending things like CMS systems or specialized services like for example Identity Server. In those situations, more often than not, the framework would be highly opinionated in what it is trying to do at the HTTP boundaries and as a result, trying to override the HTTP status codes or headers it produces may not be easy.
Let’s have a look at a simple generic workaround.
Controllers as action filters in ASP.NET Core MVC
It is common to leverage action filters when building MVC applications - this was the case in classic ASP.NET MVC, in ASP.NET Web API and is a still widely used technique (with much richer support!) in ASP.NET Core MVC.
What is not commonly known though, is that it’s possible for controllers to act as their own filters - so let’s have a look at this feature today.
Dependency injection into actions in ASP.NET Core MVC 2.1
A few years ago I blogged about dependency injection directly into actions in ASP.NET Web API. The idea is quite simple - instead of injecting all of your dependencies via the controller’s constructor, you can inject them as parameters into the action handling a given HTTP request.
This can help you prevent over-injection in the constructor; I also like this approach because it’s very verbose and clear - an action explicitly manifests what it needs to handle the request and gets just that, nothing more.
It actually works out of the box in ASP.NET Core, so let’s have a look at that and some related configuration.
dotnet-script – now on .NET Core 2.1 runtime, with C# 7.3 support and more!
In the previous post, I announced that dotnet-script is now built as global tool and can be installed using .NET Core 2.1 preview SDK. However, by that time it was still based on .NET Core 2.0 runtime (it was possible to build and install .NET Core 2.0 tools using .NET Core 2.1 preview SDK).
Now we have even more cool news to announce - because dotnet-script is now a true .NET Core 2.1 application, and can be used to run scripts on top of .NET Core 2.1 runtime. We release quite often so let me do a quick rundown of all the new features since my last blog post.
dotnet-script now available as .NET Core SDK 2.1 global tool
Yesterday we released version 0.20.0 of dotnet-script - a command line tool that allows you to run C# scripts (.csx) in the .NET Core runtime.
The highlight of this release is that it is now avaialble as .NET Core SDK 2.1 global tool, which provides an excellent acquisition/installation story directly from nuget.
Generic and dynamically generated controllers in ASP.NET Core MVC
One of those recurring themes that seem to come back fairly regularly among .NET web developers, is the usage of generic controllers to define endpoints in their Web APIs. I have witnessed these discussions as part of ASP.NET MVC, then ASP.NET Web API and most recently in ASP.NET Core MVC.
While I don’t necessarily see a huge need or benefit for generic controllers, I can imagine that - especially in enterprise context - there are scenarios where exposing similarly structured, “cookie-cutter” CRUD endpoints quickly and seamlessly, could possibly have some business value.
Let’s have a look at generic controllers then, and how we could also dynamically feed types into them.
Lightweight .NET Core benchmarking with BenchmarkDotNet and dotnet-script
Today I wanted to show you something that I hope could be a very useful addition to your .NET Core development toolbox, and that is an ultra-lightweight of doing performance benchmarking for your code using BenchmarkDotNet and dotnet-script.
We just released 0.19.0 of dotnet-script, that supports benchmarking, yesterday.
Exploring the ApiControllerAttribute and its features for ASP.NET Core MVC 2.1
ASP.NET Core MVC 2.1 will ship with a nice little feature aimed specifically at people building HTTP APIs - ApiControllerAttribute. While the stable release of 2.1 is not yet here, we can already have a look behind the scenes - what is this feature doing, and how can it help you write Web APIs.
Easy way to create a C# lambda expression from a string (with Roslyn)
I’ve worked on quite a lot of projects over the years, with many different teams, and one of the questions that keeps coming back to me over and over with a high degree of regularity is how to load a C# lambda from a string - for example from a configuration file.
This is not surprising, because being able to do that can give you a tremendous amount of flexibility in your code, as it would (for the lack of better word) unlock the possibility to alter business logic from the configuration level, without having to recompile and redeploy your application.
Historically, this has been possible but also quite a painful task. Today I wanted to show you a remarkably simple solution to this problem - with the help of the Roslyn compiler Nuget packages.
TypedRouting for ASP.NET Core MVC 2
Today I have released a new version of Strathweb.TypedRouting.AspNetCore. This new version is built as .NET Standard 2.0, and - obviously - finally supports ASP.NET Core MVC 2.
Here is a short summary and some links to help you get started.
About

Hi! I'm Filip W., a software architect from Zürich 🇨🇭. I like Toronto Maple Leafs 🇨🇦, Rancid and quantum computing. Oh, and I love the Lowlands 🏴.
You can find me on Github, on Mastodon and on Bluesky.

Recent Posts
- 2025/10/24, LLM and SLM collaboration using the Minions pattern (with Phi-4-mini and Azure OpenAI)
- 2025/09/23, Introducing (Maybe) LibOQS.NET - a post quantum cryptography library for .NET
- 2025/08/28, ML-KEM and ML-DSA Post-Quantum Cryptography in Windows
- 2025/07/14, RAG Agent with HyPE Pattern using Semantic Kernel
- 2025/06/27, AI Agents with OpenAPI Tools - Part 2: Azure AI Foundry
Categories
- ai (27)
- ai agents (4)
- ai search (5)
- apache cordova (1)
- asp.net 5 (17)
- asp.net core (47)
- asp.net mvc (35)
- asp.net mvc 6 (7)
- asp.net vnext (6)
- asp.net web api (96)
- astronomy (1)
- autogen (1)
- azure (25)
- azure service bus (1)
- azure-devops (1)
- benchmark dotnet (1)
- bing maps (1)
- blazor (2)
- c plus (2)
- c-sharp (158)
- cryptography (8)
- csharp (6)
- csharp 10 (2)
- dnx (3)
- dotnet-cli (2)
- dotnet-script (11)
- duende (4)
- editorconfig (1)
- entity framework (2)
- espn api (2)
- events (1)
- ffi (4)
- fsharp (1)
- git (1)
- glimpse (1)
- html5 (4)
- identity server (2)
- iis (2)
- il (1)
- intro to qc (19)
- ios (7)
- javascript (9)
- jquery (4)
- jquery mobile metro (1)
- katana (2)
- kindle (1)
- knockout.js (8)
- kotlin (2)
- last.fm api (2)
- linq (1)
- mac (4)
- macos (1)
- mathematica (1)
- msbuild (3)
- mvc core (3)
- nancy (2)
- native (1)
- net (144)
- net 5 (3)
- net 6 (5)
- net 7 (7)
- net 8 (3)
- net 9 (1)
- net core (49)
- net sdk (2)
- ninject (2)
- odata (4)
- oidc (2)
- omnisharp (13)
- openai (12)
- osx (2)
- owin (5)
- phi (10)
- php (1)
- pqc (6)
- promptflow (1)
- python (1)
- q-sharp (38)
- qir (3)
- qiskit (1)
- quantum computing (45)
- rag (1)
- roslyn (30)
- rust (6)
- scriptcs (11)
- scripting (9)
- security (11)
- semantic-kernel (2)
- servicestack (2)
- signalr (8)
- swift (9)
- testing (5)
- twitter boostrap (1)
- typescript (1)
- visual studio (4)
- visual studio code (11)
- wasi (3)
- wasm (3)
- windows (2)
- windows phone 7 (1)
- wordpress (1)
- wpf (2)
 
                     