JavaScriptSerializer not always returning special unicode characters like U+2028 inside JSON escaped breaking the JavaScript RRS feed

  • Question

  • User1821336047 posted


    I'm serializing JSON with JavaScriptSerializer.Serialize(obj) on a web site with .NET 4.0.30319 and MVC 4. 

    The problem is that on the prod environment with the same .NET version characters like U+2028 (line separator) or U+2029 do not get escaped to \u2028 or \u2029 as they should when serialized by .NET. The crazy thing is that locally on my environment .NET escapes them perfectly from the character itself to \u2028 or \u2029. If those characters don't get escaped (link), they break the JavaScript:

    Uncaught SyntaxError: Unexpected token ILLEGAL

    It's the same code and data I'm running on both environments. The page encoding is UTF-8. 

    I see that for .NET 4.5.1 this characters are checked (link).

    What could be causing that the character doesn't get return escaped? ISS reencoding it?


    Thursday, June 19, 2014 10:01 AM


  • User-1925713106 posted

    Hi Tatagonzalez,  

    Thanks for your post.

    I think this issue be fixed in .NET 4.5.1, please set it in your project.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 20, 2014 6:04 AM