Solution 1:

set this in startup.cs

services.Configure<CookiePolicyOptions>(options =>
        {
            // This lambda determines whether user consent for non-essential cookies is needed for a given request.
            options.OnAppendCookie = cookieContext => SameSite.CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
            options.OnDeleteCookie = cookieContext => SameSite.CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);

            //this is important. this will help you to solve the problem.
            options.MinimumSameSitePolicy = SameSiteMode.None;
        });

and add this method under the public void configure(){}

 public static class SameSite
    {
        public static void CheckSameSite(HttpContext httpContext, CookieOptions options)
        {
            if (options.SameSite == SameSiteMode.None)
            {
                if (!BrowserSupportsSameSiteNone(httpContext.Request.Headers["User-Agent"].ToString()))
                {
                    // Unspecified - no SameSite will be included in the Set-Cookie.
                    options.SameSite = (SameSiteMode)(-1);
                }
            }
        }

        private static bool BrowserSupportsSameSiteNone(string userAgent)
        {
            // iOS 12 browsers don't support SameSite=None.
            if (userAgent.Contains("CPU iPhone OS 12") || userAgent.Contains("iPad; CPU OS 12"))
            {
                return false;
            }

            // macOS 10.14 Mojave browsers don't support SameSite=None.
            if (userAgent.Contains("Macintosh; Intel Mac OS X 10_14") && userAgent.Contains("Version/") && userAgent.Contains("Safari"))
            {
                return false;
            }

            // Old versions of Chrome don't support SameSite=None.
            if (userAgent.Contains("Chrome") || userAgent.Contains("Chrome/6"))
            {
                return false;
            }

            return true;
        }
    }

Solution 2:

You'll also get this error if your website is not secure, as I found out.