4

With Visual Studio 2012, when I want to add a web service to an existing web site project, I have at least the following choices in the "Add New Item" dialog:

  • Web API Controller Class
  • AJAX-enabled WCF Service
  • Silverlight-enabled WCF Service
  • WCF Data Service
  • WCF Service
  • Web Service / ASMX (that's what I've been using until today)

(Maybe there exist even more choices, e.g. available as add-ons, extensions, NuGet packages, etc).

As far as I know, "Web API" is the newest technology for web services. Should this be used for all new development?

Or are there still situations, in which one of the other technologies should be considered? Is there any comparison of these technologies or some guidance, when to use which?

j0k
  • 22,600
  • 28
  • 79
  • 90
M4N
  • 94,805
  • 45
  • 217
  • 260
  • Some similar questions [here](http://stackoverflow.com/questions/5848069/wcf-web-api-vs-asp-net-mvc-json-web-services) and [here](http://stackoverflow.com/questions/9451298/whats-the-difference-between-wcf-web-api-and-asp-net-web-api) – StuartLC Oct 26 '12 at 13:39
  • It may help to know who you're targeting as a consumer of the web service. Although a detailed response _should_ list the intended audiences. – Joey Gennari Oct 26 '12 at 13:41
  • The consumers of the web service would be other ASP.NET applications, javascript code, .NET windows application and maybe even java applications. It should be as "interoperable" as possible. – M4N Oct 26 '12 at 13:43
  • Then you should use WCF, which can run the same service under multiple protocols. – John Saunders Oct 26 '12 at 16:33

1 Answers1

0

I don't really have a comparison, but assuming you have no legacy code or other specific requirements, I would go with the new Web API. They do basically replace the ASMX and WCF Services. They are simple to use and work similar to an MVC App.

We just switched to it and so far so good.

Remy
  • 12,555
  • 14
  • 64
  • 104
  • Updated the question. We have an existing Web Site project (if that's what you mean with legacy code). If required, I think it would be possible to convert it to a Web Application project. – M4N Oct 26 '12 at 13:42
  • It's simple to convert into a Web App. We did the same. Or you could run your webservice in a standalone project. – Remy Oct 26 '12 at 13:44