IdentityServer4 in ASP.NET Core Part 1

If you’ve worked with APIs at all in .NET Core then you have probably had the need to work with tokens for security. You could roll your own set up just using the underlying functionality in ASP.NET Identity, or you could enable easy mode and use something like IdentityServer4. There are other options out there for you to choose from, but this post will focus on IdentityServer4. Our application is going to consist of an API, a web application for IdentityServer4 and a Javascript based client. The source code for this post can be found here.
Continue reading “IdentityServer4 in ASP.NET Core Part 1”

Think Before You Use The DTO Pattern

Let me preface this blog post by saying that there are still times when a DTO makes sense. Also, this post is written from a .NET perspective, so some things may be different on your platform. What I want to address though is the tendency of many developers to just automatically create a set of DTOs for each layer for each domain model. As I mentioned in other blog posts, you should always think about why you are doing something before you are doing it. Continue reading “Think Before You Use The DTO Pattern”

The Repository Pattern is Dead If You Use Entity Framework

That is, it’s dead if you are using Entity Framework Core. If you’re still using straight ADO.NET, or even just dapper, then the repository pattern still probably makes sense for you. If you’re using Entity Framework, then you really aren’t gaining much from doing so anymore. Five years ago, you could reasonably argue that it was beneficial to use the repository pattern, or some form of abstraction, over entity framework for the following reasons:
Continue reading “The Repository Pattern is Dead If You Use Entity Framework”

Request Injection in ASP.NET Core

I’ve created a Nuget package for this called RequestInjector if you are interested in using what is discussed in this post. Source code for the package can be found here.

These days, most people are familiar with dependency injection, and in the ASP.NET world, injecting into controllers. Less people probably are familiar with Jimmy Bogard’s Mediatr, and even fewer are probably familiar with directly injecting into the request objects. All of them are viable approaches to wiring up ASP.NET Core for dependency injection, but in my opinion, some approaches are better than others.
Continue reading “Request Injection in ASP.NET Core”