Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Yogesh Chaudhari 1 post 71 karma points
    Jan 06, 2022 @ 19:46
    Yogesh Chaudhari
    0

    Adding CookiePolicyOptions to projects breaks the back office UI

    When we add CookiePolicyOptions option to Startup.cs, we can't access the back office UI.

    We see the following error in JS Console.

    Failed to load resource: the server responded with a status of 417 (The required antiforgery header value "X-UMB-XSRF-TOKEN" is not present.)

    If we remove the CookiePolicyOptions then we can access the back office UI.

    Can someone please guide me to fix this issue?

    Best regards, Yogesh

        public void ConfigureServices(IServiceCollection services)
        {
    

    pragma warning disable IDE0022 // Use expression body for methods

            services.AddDistributedMemoryCache();
    
            **services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.Strict;
            });**
    
            services.AddControllersWithViews()
                .AddSessionStateTempDataProvider();
    
            services.AddRazorPages()
                .AddSessionStateTempDataProvider();
    
            services.AddSession();
    
            services.AddUmbraco(_env, _config)
                .AddBackOffice()
                .AddWebsite()
                .AddComposers()
                .Build();
    

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft