I have an action that returns an HttpResponseMessage
.
How do I dispose such an object? After I return it, I can't really dispose it.
Example:
return new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(json, Encoding.UTF8, "application/json") };
// Inside function SomeMethod
My Action:
public HttpResponseMessage SomeAction()
{
return SomeMethod(); // Warning that this is not disposed
}
It's weird because on other parts of my code no such warning exists. Is the function confusing my IntelliSense
?
The action is not invoked from anywhere else.
It returns its result to its endpoint.