ASP.NET Core – How to manually validate a model in a controller

Manually validating a model can mean a few different things. It depends on what you’re trying to do exactly. Are you trying to validate a model object against its validation attributes? Use TryValidateModel(). Are you trying to do validation logic manually (instead of using validation attributes)? You can add errors to ModelState in that case. … Read more

ASP.NET Core – Receive a request with CSV data

There are two ways to receive CSV data in a web API: In this article, I’ll show examples of both of these approaches. I’ll be using the CsvHelper library to parse CSV data into model objects and then do model validation. Note: To use CsvHelper, install the CsvHelper package (Install-Package CsvHelper). Or use whichever parser … Read more