Implementing idempotency in .NET Core can be accomplished with a filter, which I will cover at a high level. Putting it simply, idempotency is the concept of executing an operation multiple times and getting the same result back, given the same input parameters for each request. In our case, we will be setting up idempotency […]
Unintended Side Effects with .NET Core Service Lifetimes and Dependency Injection (DI)
We have an API that handles ~45k monthly requests that was, at times, responding strangely. I suspected it was related to the .NET Core service lifetimes. The symptoms in question were that out of the blue, the API response body had a status code of 409 with a message of invalid user-provided values, however, the […]
Mocking External APIs or services in .NET
Whether calling the external API costs money or mocking desired behavior to code specific business rules. Sometimes external APIs could be mocked during the development of services or APIs. I believe this is an important strategy in every developer’s toolbox.
.NET Global Exception Handler to Return Problem Details For Your APIs
This article will focus on handling custom exceptions for flow control on .NET with a global exception handler and return a problem details object. Having said that. There are, for the most part, two schools of thought. One where it is OK to throw a (custom) exception to control flow. i.e. Throw a UserNotFoundException when […]
Configure CORS in .NET
We need to configure CORS in .NET (or really in any other language) when an application’s front-end and back-end are being served from different domains, aka origins. And more than likely, during development, both the front-end and back-end will be running from different ports on localhost.
Calling Instructure Canvas LMS API in C# ASP.NET MVC Using RestSharp
In this example I am calling the Canvas LMS API to get a list of enrolled students, including their grades, for a specific course.
Create iCal ics Files in C# ASP.NET MVC – Several Methods
Creating an iCal (ics file) is really simple. In this post I will show you how to create one using iCal.NET library and one using plain ol StringBuilder.
How to Override Default Validation Error Message for Integer or Decimal Property in ASP.NET MVC – The value ‘xxx’ is not valid for Property
Unfortunately Microsoft did not incorporate a DataAnnotation to change the default message The value ‘xxx’ is not valid for Property to a custom one. This is when you create an int or decimal property in your model, you bind it to an input box (TextBoxFor) then try to submit the form, then you get this […]
Import and Update Single Contact using Constant Contact Email Marketing API in ASP.NET (C# and VB.NET)
I will be showing you how to import and update a single contact from your third party system to Constant Contact using the Constant Contact API. Here is the API description for the POST (Create) call and PUT (Update) call.
Import Contacts in Bulk using Constant Contact Email Marketing API in ASP.NET (C# and VB.NET)
In this post I will show you how to use the Bulk Activities from the Constant Contact API to import contacts from your custom application to your Constant Contact Account.