0
I am writing a method in Webapi that returns the type Httpresponsemessage.
I have an appointment that returns a type Dynamic that would return the query of the data as it is different information.
In the return of the data an error occurs but Visual Studio complained of problems in the code. However I noticed something curious
Visual Studio error message
Error CS1973 'Httprequestmessage' has no applicable method named 'Createresponse' but appears to have an Extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the Dynamic Arguments or Calling the Extension method without the Extension method syntax.
If I put the code in the following format:
Permitted
var retorno = new { cupons = Api.Consultar(codigo) };
return Request.CreateResponse(HttpStatusCode.OK, retorno);
Not allowed
var retorno = Api.Consultar(codigo);
return Request.CreateResponse(HttpStatusCode.OK, retorno);
Assume Api.Query() returns an object of the type Dynamic
What is the difference between these two codes where one is accepted and the other is not?
What do you mean by "Not allowed"? Is there a build error? Is there a runtime error? What is the error? What is the signature of the Api method.?
– Gabriel Ferrarini
Hi @Gabrielferrarini really owed the error message, I added in the text. Thanks
– Guilherme Almeida