Output unescaped string in Razor

24. May 2012 00:03 by Mrojas in ASP.NET, HTML5, Javascript, JSON, Razor  //  Tags: , , , , ,   //   Comments (0)


 
While doing some experiments with Razor, and trying to generate some simple JSON objects in my ASP.NET MVC views
I had to deal with problems because my json string got a lot of weird " and other strange escape character.
That in general is very good but I needed my string just as is.

The current workaround that I have found for doing that is:
 
var objectInStr = @(new HtmlString(Json.Encode(Model or your object)));