Letting a request fail with Polly
Polly is fantastic for transparently retrying a request but there is always a point at which you must give up. Here you have a choice, let the request fail and inform the original caller or use the...
View ArticleRe-authorization and onRetry with Polly
Full source code available here. In a previous post I showed how to use Polly to make a simple call, retrying in the event of failure. In another I showed how to let a request fail and process the...
View ArticleReturning default values from a failed web request with Polly Fallbacks
Full source code available here. In previous posts on Polly I showed how to use a simple retry, and a retry with a delegate that is called before the request is retried. In this post I will show how...
View ArticleFluent Validation in ASP.NET Core
Full source code available here. I have written about Fluent Validation a couple of times. There is a new library available for .Net Core. How to return to validation messages back to the caller is not...
View Article.NET Core Web Api Routing
Full source code available here. Routing in .NET Core Web Api (1.1 and 2) is a little different than in earlier versions. Iāve written about this a few times, you can find those posts here. In this...
View Article.Net Core Multiple Get Methods with the Action Method Selector Attribute
Full source code available here. In .Net Core Web Api it is not possible for the routing mechanism to distinguish between the following action methods. public string GetSomething(int id, int something)...
View ArticleUnit Testing .NET Core 2 Web Api
Full source code available here. Unit testing Web API controllers in .NET Core 2 is very easy. I have very simple GET and POST methods. [Route("api/[controller]")] public class ValuesController :...
View ArticleEntity Framework Core 2 Unit Testing in .NET Core 2
Full source code available here. Unit testing Entity Framework used to be quite a chore, but over the past few years it has become significantly easier. In this post Iām going to show you how to use...
View ArticleHttpContent ReadAsAsync with .NET Core 2
Full source code available here. If you are used to using HttpContent.ReadAsAsync you might be surprised to learn that it is missing from .NET Core 2. You can try adding Microsoft.AspNet.WebApi.Client...
View ArticleReusing HttpClient with Dependency Injection
Full source code available here. If you are using HttpClient to make requests for you, you might have come across some articles discussing how to reuse HttpClient. They strongly advocate for using a...
View ArticleUnit testing Entity Framework Core Stored Procedures
Full source code available here. Entity Framework Core has made unit testing CRUD functions much easier, see here for an example of using the In Memory Database, it allows you to search, add, remove...
View ArticleUsing the Polly Timeout when making a Http Request
Full source code available here. When making remote service requests the remote side will sometimes take longer than acceptable to respond. You have a few choices in handling this. 1. Put up with it,...
View ArticleUnit Testing a Method That Uses HttpClient
Full source code available here. In this post Iām going to show you how test an action method of controller that uses a HttpClient. When performing this test you want to isolate just the code of the...
View ArticleUsing the HttpClientInterception to Test Methods That Use a HttpClient
Full source code available here. In my previous post I showed a way of testing a controller that uses a HttpClient. I had to mock the HttpMessageHandler pass that to the HttpClient and set a bunch of...
View ArticlePerforming a WHERE IN with Entity Framework or on a List
WHERE IN is a very useful and commonly used feature of SQL, it looks like this ā SELECT * FROM ORDER WHERE OrderId IN (10248, 10249, 10250, 10251) The will return up to four rows of data, showing just...
View ArticleUsing an mdf file database with Entity Framework Core 2 in Visual Studio 2017
Full source code available here. If you want to play around with Entity Framework it can be a little frustrating to create a complex database with a lot of sample data. Instead, you could download the...
View ArticleThe Circuit Breaker pattern with Polly
Full source code available here. This post on the Polly circuit breaker is part of a larger series of post on the Polly Resilience Framework, see here for the others, or check out my Pluralsight...
View ArticleEntity Framework Core, Calling Stored Procedures and Returning to a Model
Full source code available here. I wrote a post some time back about calling a stored procedure with Entity Framework using the DbCommand, but it was a bit complicated and not that easy to use. There...
View ArticleHosting a .NET Core 2 Kestrel Server in a Windows Service
Full source code available here. If you have been using the Kestrel web server with Framework 4.x, you might already be hosting Kestrel inside a Windows service. But what if you want to use Kestrel...
View ArticleSetting the Kestrel Port From Appsettings.json
Full source code available CoreWithKestrelFromConfighere. In my previous post I explained how to host Kestrel web server running on (the default) port 5000 as a Windows service. But what if you want to...
View Article