<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>HttpHandlers and HttpModules</title><link>http://forums.asp.net/27.aspx</link><description>Extending the ASP.NET Framework through HttpModules and HttpHandlers.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Format returning JSON issue from .ashx</title><link>http://forums.asp.net/thread/3264466.aspx</link><pubDate>Mon, 29 Jun 2009 14:47:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3264466</guid><dc:creator>dba123</dc:creator><author>dba123</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3264466.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3264466</wfw:commentRss><description>&lt;p&gt;Ok, I had to HtmlEncode the string before it got converted to JSON:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string imageTag = HttpUtility.HtmlEncode(string.Format(@&amp;quot;&amp;lt;img src=&amp;quot;&amp;quot;{0}&amp;quot;&amp;quot; alt=&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;gt;&amp;quot;, ImageUrl(p.Image, false)));&lt;/p&gt;&lt;p&gt;Now what I get for example in the returned JSON is:&lt;/p&gt;&lt;p&gt;[{&amp;quot;ImageTag&amp;quot;:&amp;quot;&amp;amp;lt;img src=&amp;amp;quot;http://www.xxx.com/cat_image/253.jpg&amp;amp;quot; alt=&amp;amp;quot;&amp;amp;quot;&amp;amp;gt;&amp;quot;},{&amp;quot;ImageTag&amp;quot;:&amp;quot;&amp;amp;lt;img src=&amp;amp;quot;http://www.xxx.com/cat_image/268N.jpg&amp;amp;quot; alt=&amp;amp;quot;&amp;amp;quot;&amp;amp;gt;&amp;quot;}]&lt;/p&gt;&lt;p&gt;but I want &amp;amp;lt; and &amp;amp;gt; and &amp;amp;quot to show their true values in this string.&amp;nbsp; How do I do this?&amp;nbsp; Obviously Flicker was able to (See the description value): http://api.flickr.com/services/feeds/photos_public.gne?format=json&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I am encoding my context.Response like this:&lt;/p&gt;&lt;p&gt;context.Response.ContentType = &amp;quot;text/plain&amp;quot;;&lt;br /&gt;context.Response.Charset = Encoding.UTF8.ToString();&lt;/p&gt;</description></item><item><title>Re: Format returning JSON issue from .ashx</title><link>http://forums.asp.net/thread/3264407.aspx</link><pubDate>Mon, 29 Jun 2009 14:17:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3264407</guid><dc:creator>dba123</dc:creator><author>dba123</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3264407.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3264407</wfw:commentRss><description>&lt;p&gt;ok, then in that case check out this url:&lt;/p&gt;&lt;p&gt;http://api.flickr.com/services/feeds/photos_public.gne?format=json&lt;/p&gt;&lt;p&gt;why does it show up so nicely and with no unicode crap?&amp;nbsp; I&amp;#39;m using the library arleady in .NET 3.5 so why would I need another?&lt;/p&gt;&lt;p&gt;Look at the description field, it&amp;#39;s returning an html string and that&amp;#39;s what I want to do here.&amp;nbsp; I do not want to do that in jQuery..jQuery will need to read that string as it is here for example.&amp;nbsp; I want Html tags in one of my values being returned to jQuery just like this is:&lt;/p&gt;&lt;p&gt;http://sorgalla.com/projects/jcarousel/examples/dynamic_flickr_feed.html&lt;/p&gt;&lt;p&gt;View source and check it out.&amp;nbsp; It&amp;#39;s using that url above to get the data and then uses .description which includes some HTML already.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Second, what the helll is \u003? You don&amp;#39;t see flickr as an example returning any of those unicode characters in their JSON.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Format returning JSON issue from .ashx</title><link>http://forums.asp.net/thread/3264308.aspx</link><pubDate>Mon, 29 Jun 2009 13:28:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3264308</guid><dc:creator>docluv</dc:creator><author>docluv</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3264308.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3264308</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I think you are missing the point of JSON a little. And I could be wrong. But it is supposed to be a format to transport the data portion in a consice format, not the actual HTML. You should then take that data and serilize it into an object on the client and apply render the HTML from it. That is why the AJAX templates are going to be included in ASP.NET AJAX 4.0, etc.&lt;/p&gt;
&lt;p&gt;So I would reduce your JSON to serializing the entity (image info in this case) and sending that across the wire and hydrating it on the other end and rendering it.&lt;/p&gt;
&lt;p&gt;There are several .NET JSON libraries, check the bottom of this page, &lt;a href="http://json.org/"&gt;http://json.org/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;JSON2 - &lt;a href="http://www.json.org/js.html"&gt;http://www.json.org/js.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Check out Rick Strahl&amp;#39;s blog, &lt;a href="http://www.west-wind.com/Weblog/posts/729630.aspx"&gt;http://www.west-wind.com/Weblog/posts/729630.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Format returning JSON issue from .ashx</title><link>http://forums.asp.net/thread/3263132.aspx</link><pubDate>Mon, 29 Jun 2009 03:28:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3263132</guid><dc:creator>dba123</dc:creator><author>dba123</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3263132.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3263132</wfw:commentRss><description>&lt;p&gt;I&amp;#39;m sending back a bunch of image tags via JSON in my .ashx response.&lt;br /&gt;&lt;br /&gt;I am not sure how to format this so that the string comes back with real tags.&amp;nbsp; I tried to HtmlEncode and that sort of fixed it but then I ended up with this stupid \u003c crap:&lt;br /&gt;&lt;br /&gt;[&amp;amp;quot;\u003cimg src=\&amp;amp;quot;http://www.sss.com/image/65.jpg\&amp;amp;quot; alt=\&amp;amp;quot;\&amp;amp;quot;\u003e\u003c/li\u003e&amp;amp;quot;,&amp;amp;quot;\u003cimg src=\&amp;amp;quot;http://www.xxx.com/image/61.jpg\&amp;amp;quot; alt=\&amp;amp;quot;\&amp;amp;quot;\u003e\u003c/li\u003e&amp;amp;quot;]&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What the heck is \u003c ?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;here&amp;#39;s my code that created the JSON for response to my .ashx:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void GetProductsJSON(HttpContext context)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; context.Response.ContentType = &amp;quot;text/plain&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i = 1;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...do some more stuff&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach(Product p in products)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string imageTag = string.Format(@&amp;quot;&amp;lt;img src=&amp;quot;&amp;quot;{0}&amp;quot;&amp;quot; alt=&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;gt;&amp;lt;/li&amp;gt;&amp;quot;, WebUtil.ImageUrl(p.Image, false));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; images.Add(imageTag);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string jsonString = images.ToJSON();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; context.Response.Write(HttpUtility.HtmlEncode(jsonString));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;the toJSON is simply using the helper method outlined here:&lt;br /&gt;&lt;br /&gt;http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx&lt;/p&gt;</description></item></channel></rss>