Closed silentsouls closed 8 years ago
Rather use ResponseType(typeof(HttpResponseMessage))
when actually returning something, like StatusCode(...)
in your case
While that works for now, it still is generating code that does not build. And when crating a new service this is the way VS2015 generates the attribute.
Can you please elaborate on what code it generated that does not build now?
public virtual void PutUser(Int32 id,UserModel model)
{
var result = Task.Run(() => PutUserAsyncMsg(id, model)).Result;
EnsureSuccess(result);
return result.Content.ReadAsAsync<void>().Result;
}
.ReadAsAsync<void>(). is invalid c# code the generic void is not allowed
As a best practice, one should always return something in a RESTful service. In the case where there is no content, there's stil a header present.
Use HttpResponseMessage
in this scenario
When using the api below, some invalid code will be generated.
API method:
what is generated is:
And that code will not build. Basically this line "return result.Content.ReadAsAsync().Result;" should not be generated.
The result however should be validated, to ensure success "EnsureSuccess(result);"