<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/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>Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx</link><description>ASP.NET MVC Controllers can directly return objects and collections, without rendering a view, which makes it quite appealing for creating REST like API. The nice extensionless Url provided by MVC makes it handy to build REST services, which means you</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1731747</link><pubDate>Mon, 12 Oct 2009 01:05:38 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1731747</guid><dc:creator>PimpThisBlog.com</dc:creator><description>&lt;p&gt;Thank you for submitting this cool story - Trackback from PimpThisBlog.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1731747" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1714851</link><pubDate>Tue, 11 Aug 2009 05:21:32 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1714851</guid><dc:creator>Matrich</dc:creator><description>&lt;p&gt;Hi Omar,&lt;/p&gt;
&lt;p&gt;Thanks so much for the insightful article. It was a great read. &lt;/p&gt;
&lt;p&gt;However, my question is about how scalable this approach is. I would like to know if you&amp;#39;ve done some stress testing and what were the results? Did it scale well?&lt;/p&gt;
&lt;p&gt;About Darrel&amp;#39;s comment, I would actually be surprised if I didn&amp;#39;t find any comment claiming that this is RESTful. But I think you clarified it in your response to Darrel&amp;#39;s comment.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1714851" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1693705</link><pubDate>Wed, 03 Jun 2009 11:31:38 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1693705</guid><dc:creator>Chathuranga Wijeratna</dc:creator><description>&lt;p&gt;There&amp;#39;s nothing really wrong with the approach, but if you are developing a REST API, take a look at this, which I found very useful.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.developer.com/net/article.php/10916_3695436_1"&gt;www.developer.com/.../10916_3695436_1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;because we don&amp;#39;t need ASP.NET MVC if we are only targeting a web API&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1693705" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1685937</link><pubDate>Wed, 08 Apr 2009 14:07:30 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1685937</guid><dc:creator>omar</dc:creator><description>&lt;p&gt;Moim, I agree the sample I showed is not done as per the true REST specification. But the libraries presented here that the sample uses do facilitate REST implementation. So, if you overlook the sample I made and take the libraries I made for facilitating REST over ASP.NET MVC, there&amp;#39;s no issue with making a REST API yourself. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1685937" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1685903</link><pubDate>Wed, 08 Apr 2009 11:44:50 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1685903</guid><dc:creator>Moim</dc:creator><description>&lt;p&gt;@Danny: I believe the author wrote this code only to avoid an &amp;quot;Object reference is not set to an instance of an object..&amp;quot; exception.&lt;/p&gt;
&lt;p&gt;Yes, you are right, the string.Empty.Contains .. doesn&amp;#39;t carry enough sense, but still it returns a false (which is perfectly correct in this scenairo) rather opening a possiblity of an exception raise.&lt;/p&gt;
&lt;p&gt;@Omar: IMHO, does this really comply with the definition of REST? I agree with Stephan&amp;#39;s comment here.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1685903" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1685511</link><pubDate>Tue, 07 Apr 2009 07:09:06 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1685511</guid><dc:creator>Danny</dc:creator><description>&lt;p&gt;Can someone explain the logic of this line:&lt;/p&gt;
&lt;p&gt;if ((context.HttpContext.Request.ContentType ?? string.Empty).Contains(&amp;quot;application/json&amp;quot;))&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;It&amp;#39;s my understanding that the coalesce operator identifies a null value, and if so, return an alternate value.&lt;/p&gt;
&lt;p&gt;How it&amp;#39;s being used looks like:&lt;/p&gt;
&lt;p&gt;If ContentType is null, than string.Empty.Contains(&amp;quot;...&amp;quot;);&lt;/p&gt;
&lt;p&gt;Am I missing something as this doesn&amp;#39;t look proper to me. Thanks for clarifying.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1685511" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1681034</link><pubDate>Tue, 24 Mar 2009 16:14:01 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1681034</guid><dc:creator>Awais</dc:creator><description>&lt;p&gt;Hi omar bhai,&lt;/p&gt;
&lt;p&gt;i have an islamic site , which i liked the most so i decided to share it with you..&lt;/p&gt;
&lt;p&gt;it is&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.equraninstitute.com"&gt;http://www.equraninstitute.com&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1681034" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1676537</link><pubDate>Sun, 08 Mar 2009 10:06:56 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1676537</guid><dc:creator>Tanvir</dc:creator><description>&lt;p&gt;Hi Omar, &lt;/p&gt;
&lt;p&gt;it&amp;#39;s great to find out the way to post JSON data to an action. But, if i want to use more than one JSON object parameters, how can it possible. For instance,&lt;/p&gt;
&lt;p&gt;public ActionResult UploadUser (User user, Group group){}&lt;/p&gt;
&lt;p&gt;We are using the AjaxPro.net library for the existing projects and want to shift to the asp.net MVC for the newer ones, but how to deal with this kind of problems are concerning us. Any idea?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1676537" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1666501</link><pubDate>Wed, 28 Jan 2009 07:23:46 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1666501</guid><dc:creator>Daniel</dc:creator><description>&lt;p&gt;Hi Omar,&lt;/p&gt;
&lt;p&gt;I have been struggling with XML Serialization for a few weeks now, your article was just the help I needed, thank you.&lt;/p&gt;
&lt;p&gt;The Quran Explorer is very cool too. Sura 97 verse 1 is beautiful.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1666501" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1666322</link><pubDate>Tue, 27 Jan 2009 10:22:44 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1666322</guid><dc:creator>Paul Mungai</dc:creator><description>&lt;p&gt;Hi Omar,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m developing an http web API (MVC).Your article has been useful to me. I appreciate.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Paul.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1666322" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1655079</link><pubDate>Wed, 26 Nov 2008 01:30:51 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1655079</guid><dc:creator>farid</dc:creator><description>&lt;p&gt;not yet an advance developer, so much of your article are too much for me, but stuff u had on ajax and loading and compression, seems like something my side needs to explore,, thanks for the break down explanation, &lt;/p&gt;
&lt;p&gt;also thanks for the into to quranexplorer&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1655079" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1653385</link><pubDate>Fri, 07 Nov 2008 13:15:19 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1653385</guid><dc:creator>Piers Lawson</dc:creator><description>&lt;p&gt;Nice article Omar, I picked up some ideas. If you are interested in a truely RESTful web service using ASP.Net MVC I have been writing a series of posts at &lt;a rel="nofollow" target="_new" href="http://shouldersofgiants.co.uk/blog/"&gt;shouldersofgiants.co.uk/blog&lt;/a&gt; on this subject. I too had created multiple representations (including XHTML and Help). I also supportted POST overloading. Cheers!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1653385" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1652767</link><pubDate>Sat, 01 Nov 2008 20:14:01 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652767</guid><dc:creator>Stephan</dc:creator><description>&lt;p&gt;Hi Omar,&lt;/p&gt;
&lt;p&gt;There is a nice article from Joe Gregorio:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.xml.com/pub/a/2004/12/01/restful-web.html"&gt;www.xml.com/.../restful-web.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;which describes the basic mechanisms for REST based services.&lt;/p&gt;
&lt;p&gt;Basically, your URIs will look like this:&lt;/p&gt;
&lt;p&gt;/API/User&lt;/p&gt;
&lt;p&gt;and only the HTTP methods will be different for Create,Retrieve,Update,Delete (Post,Get,Put,Delete)&lt;/p&gt;
&lt;p&gt;A nice addition is this article from the same author:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.xml.com/pub/a/2005/08/17/restful-web.html"&gt;www.xml.com/.../restful-web.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Stephan&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652767" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1651835</link><pubDate>Fri, 24 Oct 2008 06:14:56 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651835</guid><dc:creator>omar</dc:creator><description>&lt;p&gt;Hi Darrel,&lt;/p&gt;
&lt;p&gt;Good observation! I would like to understand why you think my mention of REST is wrong here.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s what I tried to convery:&lt;/p&gt;
&lt;p&gt;1) You can create REST like API using ASP.NET MVC. I do not see why this statement is wrong.&lt;/p&gt;
&lt;p&gt;2) You can accept JSON and XML payload on RESTful resources via GET and POST protocol. I do not see why this statement is wrong.&lt;/p&gt;
&lt;p&gt;REST requires that every resource must have a uniquely identifiable URI. For ex, someapi.com/API/GetUser/Scott gives you a person named &amp;#39;Scott&amp;#39;. Now, my implementation gives you further control on the representation of &amp;#39;Scott&amp;#39; resource by allowing you to consume &amp;#39;Scott&amp;#39; in either Json or POX format. &lt;/p&gt;
&lt;p&gt;I suppose if I made the URL like someapi.com/API/User/Scott and based on GET and POST, decide what action to invoke (GetUser or UpdateUser), that would look more like RESTful. But in any way, what URI you provide, how you expose and consume resources are entirely up to you. I am just enabling you to offer two more representation for your resources. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651835" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1651795</link><pubDate>Thu, 23 Oct 2008 21:52:19 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651795</guid><dc:creator>Darrel Miller</dc:creator><description>&lt;p&gt;I commend your effort but you really need to remove all traces of the word REST from this post. &amp;nbsp;Your implementation is sooooooo far from being RESTful it is scary. &amp;nbsp;I&amp;#39;m not saying there is anything wrong with your implementation, it&amp;#39;s just not REST. It &amp;nbsp;violates most of the REST constraints. &amp;nbsp;Don&amp;#39;t believe me? &amp;nbsp;Ask the guy who invented the term REST. &amp;nbsp; &lt;a rel="nofollow" target="_new" href="http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven"&gt;roy.gbiv.com/.../rest-apis-must-be-hypertext-driven&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651795" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1651282</link><pubDate>Sun, 19 Oct 2008 04:35:29 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651282</guid><dc:creator>Pathik</dc:creator><description>&lt;p&gt;Excellent article. I loved it. I made REST architecture b4 MVC came in picture and it was so difficult but this has solved all problems.&lt;/p&gt;
&lt;p&gt;Thanks Omar&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651282" width="1" height="1"&gt;</description></item><item><title>re: Create REST API using ASP.NET MVC that speaks both Json and plain Xml</title><link>http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx#1649634</link><pubDate>Fri, 03 Oct 2008 20:44:40 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1649634</guid><dc:creator>Khurram</dc:creator><description>&lt;p&gt;I love your eid gift. Its really awesome. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1649634" width="1" height="1"&gt;</description></item></channel></rss>