asp.net - web api returned content missing when posting in angularjs -
i trying post data , return content posting .net web api using angularjs
here web api
[httppost] public httpresponsemessage post() { return new httpresponsemessage() { content = new stringcontent( "<strong>test</strong>", encoding.utf8, "text/html" ) }; }
and here post client
$http({ url: 'my happy url', method: "post", data: objdata, headers: { 'content-type': 'text/html' } }).success(function (data, status, headers, config) { console.log(headers()); }).error(function (data, status, headers, config) { console.log("error"); });
my problem not data returned. sure missing simple. help.
in above code data parameter empty , expect find string "test" in data parameter.
instead of httpresponsemessage, can try use ihttpactionresult? sample code below.
public ihttpactionresult postsample() { return content(httpstatuscode.ok, "test string"); }
Comments
Post a Comment