[Solved] V13 live shows default 404 page and AntiforgeryValidationExceptions
c
Have just put a locally running V13 site live and can't get it running. The back office is fine, the Preview and Live front end pages revert to the default 404 page (rather than the one set in appsettings). In the logs there is the following error:- Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted. ---> System.Security.Cryptography.CryptographicException: The key {f1ae5c12-0cf6-4f78-863f-bb3cd0401206} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData) at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken) I've cleared all cookies and restarted but no improvement. Anyone any clues as to what I might have missed? Thanks.
Turned out the answer was to ensure I was compiling my views so they were ready for the Production environment. https://discord.com/channels/869656431308189746/1185949082271875093
The documentation is really ambiguous and could do with tightening up. In the following section of the csproj are we supposed to set these to true or comment them out? I commented them out and it worked fine. But it would be nice to have a clear explanation in the docs.
Copy code
<PropertyGroup>
    <!-- Remove RazorCompileOnBuild and RazorCompileOnPublish when not using ModelsMode InMemoryAuto
    <RazorCompileOnBuild>false</RazorCompileOnBuild>
    <RazorCompileOnPublish>false</RazorCompileOnPublish> -->
  </PropertyGroup>
63 Views