I have a web API, which I'd like to deploy. This is running well within my local dev environment. As soon as I deploy it to a Azure Web App it will fail with the following error:
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted.
---> System.Security.Cryptography.CryptographicException: The key {ca1aa6e1-29f6-4e72-a278-4ff2e2b58785} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning
So I looked up the error message and found: The anti-forgery token could not be decrypted and An exception was thrown while deserializing the token.The antiforgery token could not be decrypted in .Net Core 2.2 application.
So I added:
services.AddDataProtection()
.SetApplicationName("ccm")
.PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(Environment.ContentRootPath, @"dpkeys")));
Which works as far, that it creates the folder and an xml file in it. Anyways the error still occurs with another id, than the id of the file name.
The MS help link seems to be dead, since it refers to github but with no special information about the issue.
Any ideas, why the ids are different within the files and why the key management does not work?
I am using .net 6.0 for the API and vue for the frontend, if that makes a difference.