How to use toxiproxy to simulate web API error scenarios

When you have code that calls an endpoint, you need to make sure it’s resilient and can handle error scenarios, such as timeouts. One way to prove your code is resilient is by using toxiproxy to simulate bad behavior. Toxiproxy sits between your client code and the endpoint. It receives requests from your client, applies … Read more

C# – Conditionally catch exceptions with filtering

You can use exception filtering to conditionally catch exceptions, like this: Note: This feature was added in C# 6. Any SqlException that doesn’t meet the condition specified in the when clause will not be caught. Previously, without exception filtering, you’d have to handle that scenario in the catch block and rethrow, like this: Exception filtering … Read more

C# – How to make concurrent requests with HttpClient

The HttpClient class was designed to be used concurrently. It’s thread-safe and can handle multiple requests. You can fire off multiple requests from the same thread and await all of the responses, or fire off requests from multiple threads. No matter what the scenario, HttpClient was built to handle concurrent requests. To use HttpClient effectively … Read more