Always receiving error code "missing-input-secret" with asp.net

As the title describes, No matter what I attempt the response I always get back from server-side validation is “missing-input-secret”. Below is my code, could I be missing something or approaching it wrong?

        [HttpPost]
        public async Task<bool> TurnstileValidation()
        {
            var form = await Request.ReadFormAsync();
            var token = form["cf-turnstile-response"];

            var ip = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            var formData = new MultipartFormDataContent();
            const string SECRET_KEY = "1x00000000000000000000AA";
            formData.Add(new StringContent(SECRET_KEY, Encoding.UTF8, "application/x-www-form-urlencoded"), "secret");
            formData.Add(new StringContent(token, Encoding.UTF8, "application/x-www-form-urlencoded"), "response");
            formData.Add(new StringContent(ip, Encoding.UTF8, "application/x-www-form-urlencoded"), "remoteip");

            
            var url = @"https://challenges.cloudflare.com/turnstile/v0/siteverify";
            var client = new HttpClient();
            var response = await client.PostAsJsonAsync(url, formData);

            var returnValue = JObject.Parse(response.Content.ReadAsStringAsync().Result);
            bool result = returnValue.Value<bool>("success");
            return result;
        }

Use application/x-www-form-urlencoded for the request body, as Turnstile expects form-encoded data.
erify that you’re sending the “secret”, “response”, and “remoteip” fields correctly within the form data.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.