Development With A Dot
Blog on development in general, and specifically on .NET. Created and maintained by Ricardo Peres.
-
Unit Testing the HttpContext in Controllers
When it comes to unit testing, it is common to use mocking to replace “external” services, that is, those that are not part of the subject under test. Not everything can be mocked, and, sometimes, when we instantiate non-POCO classes, such as controllers (ControllerBase), there are lots of things that are not instantiated by the framework and are left for us do to. Just think, for example, if you want to access request or quest string data or know if the user is logged in?
-
Dynamic Routing in ASP.NET Core 3
ASP.NET Core 3 introduced a not so talked about feature which is dynamic routing. In a nutshell, it means that it is possible to decide at runtime the controller, action and route tokens that a request will be dispatched to. The idea is to map a route pattern to a dynamic route handler, like this:
-
Performance in .NET – Part 4
This is my fourth post on performance in the .NET world. See the first one on object instantiation here and the second on property copying here and the third here. This time I’m going to talk about collections, but focusing on the performance side.This time, I’ll be talking about value types.
-
Visual Studio Tips 5
This is the fifth post of my Visual Studio tips series. See the first one here, the second here, the third here and the fourth here.
-
Accessing the HttpContext from a DbContext
Sometimes it might be necessary to access the current HttpContext from inside a DbContext, namely, from inside the OnConfiguring or OnModelCreating methods. Why? Well, for once, because of multitenancy: we may want to be able to decide the connection string to use based on the requesting or the host's domain, the current user or some other request parameter. Here the internal dependency injection (Instance) can’t help, because it cannot be used inside these methods.
-
C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development - Fourth Edition Review
-
Now Reading: C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development - Fourth Edition
Update: see the review here.
-
TypeScript for C# and .NET Core Developers Review
-
Now Reading: Hands-On TypeScript for C# and .NET Core Developers
-
Succinctly Series Readers Awards