c# - string is null when posting from Angular to Web API? -
when try post string web api, value null. have tried wrapping in quotes, still null.
angularjs code:
return $http.post("http://localhost:59437/api/recaptcha/post", vcrecaptchaservice.getresponse());
web api code:
[enablecors("*", "*", "*")] public class recaptchacontroller : apicontroller { public string post([frombody] string response) { return response; } }
i not sure how works because, don't have response in form body. vcrecaptchaservice.getresponse()
returns response string , going send google's verify api verify recaptcha, [frombody] part doesn't make sense me if not part of body
your post call should sending data in json format {response: 'something'}
return $http.post("http://localhost:59437/api/recaptcha/post", { response: vcrecaptchaservice.getresponse() } //data );
Comments
Post a Comment