79410009

Date: 2025-02-03 21:02:27
Score: 1.5
Natty:
Report link

solution for .NET 8

define the following class:

internal class UnsafeAccessorClassAntiforgeryOptions
{
    [UnsafeAccessor(UnsafeAccessorKind.StaticField, Name = "DefaultCookiePrefix")]
    public static extern ref string GetUnsafeStaticFieldDefaultCookiePrefix(AntiforgeryOptions obj);
}

then in Program.cs as the first line:

UnsafeAccessorClassAntiforgeryOptions.GetUnsafeStaticFieldDefaultCookiePrefix(new()) = ".AntiForgery.";

more info about UnsafeAccessorAttribute at:

https://medium.com/@malarsharmila/introduction-to-the-unsafeaccessorattribute-class-in-net-8-0-d3a55ec15762

Reasons:
  • Blacklisted phrase (0.5): medium.com
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Cristian Olaru