XML : Valid ASP.NET XML response produces encoding error in Google Chrome

I'm using an ASP.NET WebForms page to generate XML. When I'm outputting certain XML text in Greek language inside of CData elements I get an error in Google Chrome when viewing the page in the browser.

In all other browsers it is working fine. The XML itself is valid.

The error I am getting is as follows:

This page contains the following errors:

error on line 12 at column 485: Input is not proper UTF-8, indicate encoding ! Bytes: 0xCE 0xAE 0x20 0xCF

I'm using Chrome version 51.0.2704.84 m

I can easily reproduce the issue with a simple WebForms page with a constant string value. See example here http://pastebin.com/pVB5MFHq, you can also try it out by creating this ASPX page in a web project and simply loading it in Chrome.

It seems like Chrome doesn't break because of certain part of the XML, but because of the whole XML byte array itself. If I use XML encoding instead of CData, then it works fine, but that's not what I want.

I tried to play around with setting encoding and response headers, but I couldn't figure out what the issue might. Maybe it's a Chrome bug, or I'm missing something.

I have also tried recommendations described here How to return XML in ASP.NET?

No comments:

Post a Comment