<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: How to serve the same data in Json, Xml or Html with Asp.Net Mvc revised</title>
	<atom:link href="http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/feed/" rel="self" type="application/rss+xml" />
	<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/</link>
	<description>One is glad to be of service</description>
	<pubDate>Fri, 12 Mar 2010 07:58:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mark Jensen</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53749</link>
		<dc:creator>Mark Jensen</dc:creator>
		<pubDate>Sat, 18 Jul 2009 10:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53749</guid>
		<description>Hi Dave

Thank you for pointing that out - I know that it might seem like a problem, but you can do two things...

1. Do like Joel and add a route ex. "{controller}/{action}/{id}.{format}"

or

2. Make your own ModelBinder - Haven't tested this, but I guess it could work.</description>
		<content:encoded><![CDATA[<p>Hi Dave</p>
<p>Thank you for pointing that out - I know that it might seem like a problem, but you can do two things&#8230;</p>
<p>1. Do like Joel and add a route ex. &#8220;{controller}/{action}/{id}.{format}&#8221;</p>
<p>or</p>
<p>2. Make your own ModelBinder - Haven&#8217;t tested this, but I guess it could work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53626</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Sat, 18 Jul 2009 01:26:59 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53626</guid>
		<description>Great work! I like specifying the extension in the url. Other methods I have seen require setting the content type of the request.

I didnt realise at first I needed to add the route from your first post. After I did this it worked beautifully.</description>
		<content:encoded><![CDATA[<p>Great work! I like specifying the extension in the url. Other methods I have seen require setting the content type of the request.</p>
<p>I didnt realise at first I needed to add the route from your first post. After I did this it worked beautifully.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53552</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 17 Jul 2009 20:07:23 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53552</guid>
		<description>Doh! My bad on the .Any thing - I did not have a using System.Linq!

Dave</description>
		<content:encoded><![CDATA[<p>Doh! My bad on the .Any thing - I did not have a using System.Linq!</p>
<p>Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53550</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 17 Jul 2009 19:09:28 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53550</guid>
		<description>I really like this idea, but when I started playing with this I ran into a snag that's worth noting...

I setup an Order method in the home controller, and gave it this signature:

public ActionResult Order(int id)
{
 //Stuff returning a view w/ data
}

I then hit http://foo/home/order/23.json

The problem is that when the route is parsed, it interprets 23.json as a string input type for the id argument, and throws an exception. doh!

If I change the argument type to string, it works, except now I have to strip the extension, and cast to an int so my repository can fetch the correct data.

From what I can see of ActionFilters, I don't think we can strip the extension off before the action is executed. 

Anyhow - I'm going to stick with our current methodology using query string parameters (&amp;f=json)

Also - your code uses an extension method on Array (Array.Any) - it would be handy if you could reference where that comes from and/or add it to http://www.extensionmethod.net

Cheers,

Dave</description>
		<content:encoded><![CDATA[<p>I really like this idea, but when I started playing with this I ran into a snag that&#8217;s worth noting&#8230;</p>
<p>I setup an Order method in the home controller, and gave it this signature:</p>
<p>public ActionResult Order(int id)<br />
{<br />
 //Stuff returning a view w/ data<br />
}</p>
<p>I then hit <a href="http://foo/home/order/23.json" rel="nofollow">http://foo/home/order/23.json</a></p>
<p>The problem is that when the route is parsed, it interprets 23.json as a string input type for the id argument, and throws an exception. doh!</p>
<p>If I change the argument type to string, it works, except now I have to strip the extension, and cast to an int so my repository can fetch the correct data.</p>
<p>From what I can see of ActionFilters, I don&#8217;t think we can strip the extension off before the action is executed. </p>
<p>Anyhow - I&#8217;m going to stick with our current methodology using query string parameters (&amp;f=json)</p>
<p>Also - your code uses an extension method on Array (Array.Any) - it would be handy if you could reference where that comes from and/or add it to <a href="http://www.extensionmethod.net" rel="nofollow">http://www.extensionmethod.net</a></p>
<p>Cheers,</p>
<p>Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53489</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 17 Jul 2009 14:14:11 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53489</guid>
		<description>Very nice - we have implemented similar functionality, but not as cleanly. Basically we use a format in the query string instead of an extension, but now that I see your code... ;-) 

One thing we find we use a lot is a "partial" option. This allows our client side code to call back for rendered HTML for just a part of the page. Something you may want to consider.

Cheers,

Dave</description>
		<content:encoded><![CDATA[<p>Very nice - we have implemented similar functionality, but not as cleanly. Basically we use a format in the query string instead of an extension, but now that I see your code&#8230; ;-) </p>
<p>One thing we find we use a lot is a &#8220;partial&#8221; option. This allows our client side code to call back for rendered HTML for just a part of the page. Something you may want to consider.</p>
<p>Cheers,</p>
<p>Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #392</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53408</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #392</dc:creator>
		<pubDate>Fri, 17 Jul 2009 07:41:44 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53408</guid>
		<description>[...] How to serve the same data in Json, Xml or Html with Asp.Net Mvc revised - Mark Jensen shares some code to allow you to easily return data in a number of different formats in ASP.NET MVC (rather like the way rails does). This code is destined for the mvccontrib project, so expect to see it used in lots of places. [...]</description>
		<content:encoded><![CDATA[<p>[...] How to serve the same data in Json, Xml or Html with Asp.Net Mvc revised - Mark Jensen shares some code to allow you to easily return data in a number of different formats in ASP.NET MVC (rather like the way rails does). This code is destined for the mvccontrib project, so expect to see it used in lots of places. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Jensen</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53169</link>
		<dc:creator>Mark Jensen</dc:creator>
		<pubDate>Thu, 16 Jul 2009 13:03:44 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53169</guid>
		<description>Thanks :)</description>
		<content:encoded><![CDATA[<p>Thanks :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eric hexter</title>
		<link>http://fatagnus.com/how-to-serve-the-same-data-in-json-xml-or-html-with-aspnet-mvc-revised/comment-page-1/#comment-53151</link>
		<dc:creator>eric hexter</dc:creator>
		<pubDate>Thu, 16 Jul 2009 12:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://fatagnus.com/?p=341#comment-53151</guid>
		<description>looks good.  I know we are running pretty slow on evaluating patches for mvccontrib.. it usually happens on weekend nights.</description>
		<content:encoded><![CDATA[<p>looks good.  I know we are running pretty slow on evaluating patches for mvccontrib.. it usually happens on weekend nights.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
