0

I am writing a webhook in C# to receive messages, change state and so on from whatsapp business platform.

My webhook receives data correctly from meta, but I cannot understand how to convalidate URL.

This is my very simple code

public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string hubMode = Request["hub.mode"];
        string hubChallenge = Request["hub.challenge"];
        string hubVerify_token = Request["hub.verify_token"];
        if (hubVerify_token == "pippoplutopaperino")
        {
            Response.Write(hubChallenge);
        }
    }
}

in the response write I receive this error:

enter image description here

Why, after hubChallenge, there are \r\n\r\n\u etc??????

Where am I doing wrong?

I expect to response witjh only hubChallenge

Palle Due
  • 5,929
  • 4
  • 17
  • 32
Demo
  • 1

1 Answers1

0

By the looks of the error message you are writing to the page without clearing or ending the stream so its appending the aspx markup onto the page.

You should either use a generic handler instead, or explicitly clear the webpage's response by doing

Context.Response.Clear()

so that it doesn't try to append any HTML content.

gsck
  • 81
  • 4
  • Thankyou, but it seem a bug of the meta platform. After some tries with different solutions, returning to the firs one, the webhook has been accepted. – Demo Jul 05 '23 at 18:12