© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
5 replies
no >> body

OnAppendCookie callback doesn't work

I have an ASP.NET Core project, which uses IdentityServer4. In my configuration I have CookiePolicyOptions which contains the next setup:

services.Configure<CookiePolicyOptions>(
    option =>
    {
        option.MinimumSameSitePolicy = SameSiteMode.None;
        option.HttpOnly = Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy.Always;
        option.OnAppendCookie = cookieContext =>
        {
            Console.WriteLine("Cookie appended: " + cookieContext.CookieName);
        };
        option.OnDeleteCookie = context =>
        {
            Console.WriteLine("Cookie deleted: " + context.CookieName);
        };
    });
services.Configure<CookiePolicyOptions>(
    option =>
    {
        option.MinimumSameSitePolicy = SameSiteMode.None;
        option.HttpOnly = Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy.Always;
        option.OnAppendCookie = cookieContext =>
        {
            Console.WriteLine("Cookie appended: " + cookieContext.CookieName);
        };
        option.OnDeleteCookie = context =>
        {
            Console.WriteLine("Cookie deleted: " + context.CookieName);
        };
    });


For some reason, I can't reach the code from the OnAppendCooie and OnDeleteCookie.
I've also added a custom filter to append a new cookie to the response. The behavior was still the same - OnAppendCookie and OnDeleteCookie were not called.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Filter doesn't work
C#CC# / help
3y ago
❔ External Login Callback (Facebook works, Google doesn't)
C#CC# / help
4y ago
✅ Enum comparison doesn't work.
C#CC# / help
17mo ago
why this doesn't work
C#CC# / help
2y ago