Post-Redirect-Get and TempData with ASP.NET Core

The Post-Redirect-Get (PRG) pattern prevents duplicate form submissions when the user refresh the page. Here's the sequence diagram: As you can see, the server query the database twice to display the page to the user. This is inefficient, but how can you improve this? The time between the two requests is very short (about 1 second). So, maybe you can store the object in memory, and reuse it when the user… [read more]

ASP.NET Core - Precompiling razor views

Improving the startup time of your website is important. There are many reasons for a website to take times to get ready: loading lots of dll, loading data, compiling views, etc. In this post, I'll explain how to reduce the startup time by precompiling razor views. The view precompilation is a build step that generates a DLL from the cshtml. Instead of doing the view compilation at runtime the first time… [read more]

FileSystemWatcher intermittently throws an exception on Linux

In my quest of hosting my ASP.NET Core web sites on Linux, I encounter an intermittent exception: System.IO.IOException: The configured user limit (128) on the number of inotify instances has been reached. at System.IO.FileSystemWatcher.StartRaisingEvents() at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed() ... This exception occurs when I instanciate a FileSystemWatcher. To protect… [read more]

Publishing an ASP.NET Core website to a Linux host

I recently move my web site to a Linux host, remember, .NET Core is multi-platform 😃 This choice is mainly motivated by the price. Indeed, you can find many cheap VPS providers (Virtual Private Server) on the internet. For instance, you can choose OVH. They have great VPS for about 3€ per month (I'm not paid by them, but I've been using their services for a few years without any issue). Hosting a site on… [read more]