jonhobbs
jonhobbs

Reputation: 27952

How to create a RESTful web service in asp.net?

I simply want to create a fairly basic REST service, so that I can expose some of the data in my asp.net/SQL server application to the outside works, like this.....

http://domain.com/api/offices - would return an xml set of office locations. http://domain.com/api/offices/15 - would return all the details of office 15.

It's all fairly standard stuff (including basic authentication) but there seem to be several ways to achieve this using Microsoft technologies and I don't really know where to start. These seem to be the options...

1) WCF

2) ASP.NET MVC

3) ADO.NET Data Services

4) Rest Starter Kit project templates?

Which of these is the easiest and most "up-to-date" solution to creating a web service?

Upvotes: 3

Views: 1534

Answers (3)

TMN
TMN

Reputation: 3070

ADO.NET Data Services is now WCF Data Services, and that's what I'd recommend. It's pretty easy to work with (at least for the type of services you describe). You might also want to take a look at the Open Data Protocol -- you probably don't need it, unless you're supporting non-.NET clients (PHP, Java).

Upvotes: 1

roundcrisis
roundcrisis

Reputation: 17795

There are a few alternatives, not sure if you heard of them but might as well look into them:

  • Open Rasta IT s a fairly opinionated Rest framework that lets you create web services and web sites, its a bit weird to get your head around it first but; its so light weight that makes sense to give it a go, it requires some idea on how Rest actually works (and not the .net abstraction that you might be used to) and i think it doesnt have a very strong dependency on asp.net, an obvious advantage to me is that you can encode to HTML, JSON or any format you might need, its quite interesting

  • Another option out there, (that I havent used), is Siesta, wich works on top of Asp.net mvc

Wcf configuration can get very painful very quickly...

Hope it helps

Upvotes: 2

Justin Niessner
Justin Niessner

Reputation: 245389

If you don't plan on adding any other endpoints in the future (like SOAP, etc.) and the Service isn't going to be consumed by a Silverlight client, I would suggest using ASP.NET MVC.

If Silverlight is involved, then use ADO.NET Data Services.

If you plan on building out a robust Service framework with multiple endpoint types, then use WCF.

Upvotes: 2

Related Questions