79729507

Date: 2025-08-08 08:31:39
Score: 1
Natty:
Report link

To build on @DibsyJr's answer, I've created an attribute that I attach on the controller/method that I want to block, and check it in the OnCheckSlidingExpiration event handler. I find that more flexible than just checking the path property.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class DoNotRenewAuthCookieAttribute : Attribute;
options.Events.OnCheckSlidingExpiration = context =>
{
    if (context.HttpContext.GetEndpoint()?.Metadata.Any(e => e is DoNotRenewAuthCookieAttribute) ?? false)
    {
        context.ShouldRenew = false;
    }

    return Task.CompletedTask;
};
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: ToufiPF