My ASP.Net Core MVC application have added Antiforgery middleware like below:
startup.cs
services.AddMvc();
services.Ad
I've had exactly that error on a ASP .net core app hosted on a linux container.
From the docs it would seem if you don't meet certain criteria the keys are only persisted in the process - but that even for me was not working.
First the error occurred with the default setup.
I then added specific configuration for the keys on the filesystem:
services.AddDataProtection()
.PersistKeysToFileSystem(new System.IO.DirectoryInfo(@"/var/my-af-keys/"));
This also didn't fix the issue I had to set an application name:
services.AddDataProtection()
.SetApplicationName("fow-customer-portal")
.PersistKeysToFileSystem(new System.IO.DirectoryInfo(@"/var/dpkeys/"));
I haven't confirmed but its possible nature of the LXC hosting means .net core cannot persist the identity of the app.