'BOM Preamble in .NET Rest API causing Twilio Parse Error 12100

We have a .NET Rest API that is a web-hook for Twilio. It returns a TwilioResponse object. Suddenly, Twilio is reporting a Parse Error 12100 on the hook. We looked closer and it seems to be due to a BOM preamble that is getting added to our response now (for some reason; this code hasn't changed in years).

Does anyone know what might cause this problem to suddenly crop up. And, more importantly, how can I fix it?

Here is the HttpGet method that Twilio is calling (and choking on)...

        [HttpGet]
        [Route("TransferMessage", Name = "GetTransferMessage")]
        public TwilioResponse GetTransferMessage()
        {
            var response = new TwilioResponse();
            response.Pause(2);
            response.Say("Hello. This call is being transferred by Acme Products and may be recorded " +
                "for quality assurance.");

            return response;
        }

Thanks in advance...!

Here is the xml returned by our endpoint. If you look at the raw data in a hex editor, it's clearly encoded with UTF-8-BOM.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source