How to use multiple hosting environments on the same machine in ASP.NET Core
This short post is in response to a comment I received on a post I wrote a while ago, about how to set the hosting environment in ASP.NET Core. It's a question I've heard a couple of times, so thought...
View ArticleThe Microsoft.AspNetCore.All metapackage is huge, and that's awesome, thanks...
In the ASP.NET Core 2.0 preview 1 release, Microsoft have released a new metapackage called Microsoft.AspNetCore.All. This package consists of every single package shipped by Microsoft as part of...
View ArticleUsing ImageSharp to resize images in ASP.NET Core - Part 4: saving to disk
This is the next in a series of posts on using ImageSharp to resize images in an ASP.NET Core application. I showed how you could define an MVC action that takes a path to a file stored in the wwwroot...
View ArticleDefining custom logging messages with LoggerMessage.Define in ASP.NET Core
One of the nice features introduced in ASP.NET Core is the universal logging infrastructure. In this post I take a look at one of the helper methods in the ASP.NET Core logging library, and how you...
View ArticleAutomatically validating anti-forgery tokens in ASP.NET Core with the...
This quick post is a response to a question about anti-forgery tokens I saw on twitter: I want to apply ValidateAntiForgeryToken to every action on all HttpPost requests in #AspNetCore MVC. Any easy...
View ArticleFour ways to dispose IDisposables in ASP.NET Core
One of the most commonly implemented interfaces in .NET is the IDisposable interface. Classes implement IDisposable when they contain references to unmanaged resources, such as window handles, files...
View ArticleController activation and dependency injection in ASP.NET Core MVC
In my last post about disposing IDsiposables in ASP.NET Core, Mark Rendle pointed out that MVC controllers are also disposed at the end of a request. On first glance, this may seem obvious given that...
View ArticleWhen you use the Polly circuit-breaker, make sure you share your Policy...
This post is somewhat of PSA about using the excellent open source Polly library for handling resiliency to your application. Recently, I was tasked with adding a circuit-breaker implementation to...
View ArticleLocalising the DisplayAttribute in ASP.NET Core 1.1
This is a very quick post in response to a comment asking about the state of localisation for the DisplayAttribute in ASP.NET Core 1.1. A while ago I wrote a series of posts about localising your...
View ArticleCreating custom password validators for ASP.NET Core Identity
ASP.NET Core Identity is a membership system that lets you add user accounts to your ASP.NET Core applications. It provides the low-level services for creating users, verifying passwords and signing...
View ArticleCreating a validator to check for common passwords in ASP.NET Core Identity
In my last post, I showed how you can create a custom validator for ASP.NET Core. In this post, I introduce a package that lets you validate that a password is not one of the most common passwords...
View ArticleBuilding ASP.NET Core 2.0 preview 2 packages on AppVeyor
I was recently creating a new GitHub project and I wanted to target ASP.NET Core 2.0 preview 2. I like to use AppVeyor for the CI build and for publishing to MyGet/NuGet, as I can typically just copy...
View ArticleCustomising ASP.NET Core Identity EF Core naming conventions for PostgreSQL
ASP.NET Core Identity is an authentication and membership system that lets you easily add login functionality to your ASP.NET Core application. It is designed in a modular fashion, so you can use any...
View ArticleHow to format response data as XML or JSON, based on the request URL in...
I think it's safe to say that most ASP.NET Core applications that use a Web API return data as JSON. What with JavaScript in the browser, and JSON parsers everywhere you look, this makes perfect...
View ArticleIntroduction to the ApiExplorer in ASP.NET Core
One of the standard services added when you call AddMvc() or AddMvcCore() in an ASP.NET Core MVC application is the ApiExplorer. In this post I'll show a quick example of its capabilities, and give...
View ArticleThe SDK 'Microsoft.Net.Sdk.Web' specified could not be found
This article describes why you get the error "The SDK 'Microsoft.Net.Sdk.Web' specified could not be found" when creating a new project in Visual Studio 2017 15.3, which prevents the project from...
View ArticleUsing CancellationTokens in ASP.NET Core MVC controllers
In this post I'll show how you can use a CancellationToken in your ASP.NET Core action method to stop execution when a user cancels a request from their browser. This can be useful if you have long...
View ArticleAligning strings within string.Format and interpolated strings
I was browsing through the MSDN docs the other day, trying to remind myself of the various standard ToString() format strings, when I spotted something I have somehow missed in all my years of .NET -...
View ArticleCreating a rolling file logging provider for ASP.NET Core 2.0
ASP.NET Core includes a logging abstraction that makes writing logs to multiple locations easy. All of the first-party libraries that make up ASP.NET Core and EF Core use this abstraction, and the...
View ArticleHow to include scopes when logging exceptions in ASP.NET Core
This post describes how to work around an issue I ran into when logging exceptions that occur inside a scope block in ASP.NET Core. I'll provide a brief background on logging in ASP.NET Core,...
View Article