Not So RESTful Days
by Flash
- Published:May 19th, 2009
- Comments:No Comment
- Category:.NET 3.5, ASP.NET
One of my clients asked me to write a very simple RESTful web service to retrieve user data (name, email, address, etc.) based on login credentials. Having recently finished working on a PHP-driven RESTful interface for another client (based on the Zend Framework), I thought this would be a simple and straightforward task. As comedian Bill Engvall says: "Here's your sign!". I should have known better.
My first effort was to simply refactor my previous work. It took me a few hours but it worked great... on my development machine. However, once I ported it to the host for testing, it crapped out because they host their site on a Windows server under IIS7. So, having very little control, there goes the possibility for url rewrites (on the server level).
Next, I thought back to an recent WNC .NET Developer's Guild presentation given by Joel Reyes (of Microsoft) entitled ADO.NET Data Services. His code examples demonstrated a simple RESTful service in action. So, another few hours and I had a great working example. A few hours?!? Well, I had to download a few things to get my Windows XP up to snuff (such as .NET 3.5 SP1 among other things). There was my next sign... it didn't occur to me then that the host (Web.com) wasn't up to date either. Too late! After I deployed a quick test app I realized they were behind the times when I got this error:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 33: <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
Source File: \\HOSTING\DFS\20\3\3\4\2030628433\user\sites\dampp-chaserdb.com\www\test\web.config Line: 33
As a sidebar... I tried to ask their front-line technical support staff for some information on their current version of the .NET framework and if they had a workaround for URL rewrites on the box the site was hosted on. Yeah right!. That was another wasted 30 minutes.
Alack! And Alas! I decided it was time to force feed myself some ASP.NET MVC and quick. ASP.NET MVC has the ability to return XML and JSON via a RESTful interface. So, to keep this note short, I'm heading back to tuck into some tutorials. I purchased Effective REST Services via .NET by Kenn Scribner and Scott Seely so I've got to read through it quick. I'm also using blog posts from Piers Lawson as a guide. Here's a link to Part 1. Just filter by the REST tag to get a list of the other posts in the series. There's a bunch there.
One helpful note: If you find yourself using Piers' posts like I did, I had to fix an error that was preventing me from getting the same results as he did. In Part 1 in the Guid.aspx file use this code snippet instead of his example:
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
<ul class="guids">
<% foreach (var guid in (IEnumerable)ViewData.Model)
{
%>
<li><%= guid.ToString().ToUpper()%></li>
<% } %>
</ul>
</asp:Content>
This may be because of the version of ASP.NET he used as compared to the latest bits.
I really dig MVC having been first exposed to it when writing custom components in Joomla. I'm psyched now that I have the chance to mix some MVC peanut butter with some ASP.NET chocolate. Now I'm off to get some REST.
(That was lame, sorry)


No Comment
No comments yet.