5 ways to set the URLs for an ASP.NET Core app
By default, ASP.NET Core apps listen on the following URLs: http://localhost:5000 https://localhost:5001 In this post I show 5 different ways to change which URLs your app listens on. There are...
View ArticleHow to automatically choose a free port in ASP.NET Core 3.0
This post is in response to a discussion I had with a friend recently who was trying out .NET Core. Unfortunately, when they attempted to start their new application they received the following...
View ArticleAdding simple email address obfuscation for your blog like Cloudflare Scrape...
In this post I show a simple way to obfuscate email addresses to make it harder for bots to scrape them from your site. It uses a similar approach as Cloudflare Scrape Shield. It's important to not...
View ArticlePreventing mass assignment or over posting with Razor Pages in ASP.NET Core
Mass assignment, also known as over-posting, is an attack used on websites that use model-binding. It is used to set values on the server that a developer did not expect to be set. This is a well known...
View ArticleUsing jQuery and Bootstrap from a CDN with fallback scripts in ASP.NET Core 3.0
In this post, I show how to use the Link Tag Helper and Script Tag Helper in Razor with the asp-fallback attribute to serve files from a Content Delivery Network (CDN), falling back to local scripts if...
View ArticleExtending the shutdown timeout setting to ensure graceful IHostedService...
I was seeing an issue recently where our application wasn't running the StopAsync method in our IHostedService implementations when the app was shutting down. It turns out that this was due to some...
View ArticleHandling Web API Exceptions with ProblemDetails middleware
In this short post I describe a handy error-handling middleware, created by Kristian Hellang, that is used to return ProblemDetails results when an exception occurs. ProblemDetails and the...
View ArticleStrongly-typed ID update 0.2.1: Using strongly-typed entity IDs to avoid...
Last year I wrote a series about using strongly typed IDs to avoid a whole class of bugs in C# applications. In this post I describe some recent updates to a NuGet package that drastically reduces the...
View ArticleCustomising the ASP.NET Core default UI without editing the PageModels
ASP.NET Core Identity includes a default UI as a Razor library that enables you to quickly add users to an application, without having to build all the UI yourself. The downside is that if you want to...
View ArticleSetting global authorization policies using the DefaultPolicy and the...
ASP.NET Core has an extensive authorization system that you can use to create complex authorization policies. In this post, I look at the various ways you can apply these policies to large sections of...
View ArticleAdding host filtering to Kestrel in ASP.NET Core
Host filtering, restricting the hostnames that your app responds to, is recommended whenever you're running in production for security reasons. In this post, I describe how to add host filtering to an...
View ArticleGetting started with ASP.NET Core
The Manning Early Access Program (MEAP) has started for the second edition of my book ASP.NET Core in Action, Second Edition. This post gives you a sample of what you can find in the book. If you like...
View ArticleVisualizing ASP.NET Core endpoints using GraphvizOnline and the DOT language
In this post I show how the endpoint routes in an ASP.NET Core 3.0 application can be visualized using the GraphvizOnline service. That lets you create diagrams like the following, which describe all...
View ArticleAdding an endpoint graph to your ASP.NET Core application: Visualizing...
In this post I show how to visualize the endpoint routes in your ASP.NET Core 3.0 application using the DfaGraphWriter service. I show how to generate a directed graph (as shown in my previous post)...
View ArticleCreating a custom DfaGraphWriter using ImpromptuInterface for easier...
In this post I lay the groundwork for creating a custom implementation of DfaGraphWriter. DfaGraphWriter is public, so you can use it in your application as I showed in my previous post, but all the...
View ArticleCreating a custom DfaGraphWriter using ImpromptuInterface for easier...
In this post I lay the groundwork for creating a custom implementation of DfaGraphWriter. DfaGraphWriter is public, so you can use it in your application as I showed in my previous post, but all the...
View ArticleCreating a custom endpoint visualization graph: Visualizing ASP.NET Core 3.0...
In this series, I've been laying the groundwork for building a custom endpoint visualization graph, as I showed in my first post. This graph shows the different parts of the endpoint routes: literal...
View ArticleDetecting duplicate routes in ASP.NET Core: Visualizing ASP.NET Core 3.0...
In this series, I have shown how to view all the routes in your application using an endpoint graph. In this post I show how to do something more useful—detecting duplicate routes that would throw an...
View ArticleExploring the code behind IHttpClientFactory in depth
In this post I take a look at the code in the default implementation of IHttpClientFactory in ASP.NET Core—DefaultHttpClientFactory. We'll see how it ensures that HttpClient instances created with the...
View ArticleDI scopes in IHttpClientFactory message handlers don't work like you think...
In this post I discuss how dependency injection scopes work in the context of IHttpClientFactory. The title of this post reflects the fact that they don't work like I previously expected them to! This...
View Article