tags:

views:

129

answers:

2

I have to return a JsonResult, which contains some HTML.

so, something like:

return Json(new { id="guid", html="<param id='id'/>" });

However when I get the result back , the angel bracket are encoded as u003e, u003c , etc..

I tried various encoders but can't figure this one out. Anyone run into this?

I can return a Content(string) with the Response.ContentType = "application/json" without this issue, but my json object is pretty complex and rather return a JsonResult if possible.

Thanks!

+1  A: 

This is done to prevent potential XSS attacks by inserting malicious HTML tags in your data. It shouldn't have a functional difference for you. "\uxxxx" represents the same character as the unencoded version.

Mehrdad Afshari
+1  A: 

That's just Unicode. Once you show it in the browser it will look fine (if the browser is your client application).

Luca Matteis