return Request.CreateResponse(HttpStatusCode.BadRequest, new mymethodresponse
{
ID= Idval,
Created= false
}
Here how to create more overloads for createresponse method
CodePudding user response:
Below is a work demo, you can refer to it.
1.Create a HttpRequestMessageExtensions class
public static class HttpRequestMessageExtensions
{
public static HttpResponseMessage CreateResponse(this HttpRequestMessage request, HttpStatusCode statusCode, string TestParas)
{
return new HttpResponseMessage
{
StatusCode = statusCode,
RequestMessage = request
};
}
}
2.In controller like below
public class OverloadController : Controller
{
public HttpResponseMessage Call(HttpRequestMessage RequestMessage)
{
return RequestMessage.CreateResponse();//do your staff...
}
}