Thomas Ardal

Thomas Ardal

Denmark
215 posts
ASP.NET Core request logging middleware

I needed to debug an error logged through Microsoft.Extensions.Logging (MEL) on one of our ASP.NET Core-based services today. Usually, when getting errors logged through MEL, all of the HTTP context data is logged as part of the error, making it easy to spot why an error happened ...

The ultimate guide to secure cookies with web.config in .NET

TOCThis is the fourth post in a series about ASP.NET security: Part 1: Improving security in ASP.NET MVC using custom headers Part 2: Content-Security-Policy in ASP.NET MVC Part 3: Storing Content-Security-Policy reports in elmah.io Part 4: The ultimate guide to secure cookies with web.config in ...

Find anomalies with spike detection and ML.NET

We recently started experimenting with machine learning on elmah.io. There's a closed beta on anomaly detection and more, similar features will follow in the future. We chose ML.NET as the framework and are pretty happy with the results so far. The amount of documentation is good but mostly ...

Debugging System.NullReferenceException - Object reference not set to an instance of an object

Time for another post in the series Debugging common .NET exceptions. Today's exception is, without a doubt, the error most people have experienced: System.NullReferenceException. The exception happens when you try to invoke a reference that you were expecting to point to an object but in fact, points to null. ...

How to write to a file with C# in 2019 - StackOverflow doesn't get it right

Today's tip isn't exactly about a hot new version of ASP.NET Core or anything like that. I often find myself googling "simple" questions like how to write text to a file in the most quickly and effectively way. Most results are either blog posts using .NET 2 as an ...

C# exception handling best practices

I'm getting near my 20th anniversary in the tech industry. During the years, I have seen almost every anti-pattern when dealing with exceptions (and made the mistakes personally as well). This post contains a collection of my best practices when dealing with exceptions in C#. Decorate exceptionsI see this used ...

Fix max URL and query string length with web.config and IIS

I had a problem the other day that I believe qualifies as a blog post. An elmah.io user reported that refreshing the organization overview would generate a 404. After debugging the problem, I found out that the URL generated by that page can be too long. This post is ...

Partner with BrowserStack to support real-device debugging

When dealing with client-side errors, the combination of a physical device, the operating system, and the browser can be the cause of an error. You probably don't have an old Samsung Galaxy S4 running Android 4 laying in your drawer. Debugging errors like this can be extraordinarily painful, and even ...

Migrating the elmah.io API to ASP.NET Core

We just launched a brand new version of our API. The big difference is that the API is now running on ASP.NET Core (instead of ASP.NET Web API). The new API is backward compatible with all of the existing integrations already using Elmah.Io.Client version 3.x. ...