My ashx page is returning a body but I only want to send a status code 200

587 Views Asked by At

I've set up an ashx page to receive a webhook notification. However, I'm getting and error from the webhook provider that my response contains a body. For the moment I just want to send a status code of 200. This is my code :-

public class updateTS : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.StatusCode = 401;
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

As far as I can see my content does not have a body. What am I doing wrong?

1

There are 1 best solutions below

6
JustAnotherDev On

Use context.Response.Clear() first to empty the response and set the StatusCode to 200:

    context.Response.Clear()
    context.Response.StatusCode = 200;