I am trying to send my cached response back to the client but have an error
System.InvalidOperationException: The response cannot be cleared, it has already started sending.
I am trying to modify response to prevent sending my request further to third-party API
var result = await priceFilter.ValidateRequest(document);
if (result != null && !_httpContext.Response.HasStarted)
{
HttpResponse response = _httpContext.Response;
response.Clear();
var buffer = Encoding.UTF8.GetBytes(result);
response.StatusCode = 200;
response.ContentType = "text/xml;charset=utf-8";
response.ContentLength = buffer.Length;
await response.Body.WriteAsync(buffer, 0, buffer.Length);
}