There have been a lot of debates lately on which technology to use when it comes to building web services for various client applications in the .NET world. Which one should we use, WCF or ASP.NET Web API?

Let us first describe the two technologies. WCF is a framework for building service-oriented applications on the .NET framework. ASP.NET Web API is a framework for building RESTful application on the .NET framework.

In my opinion, choosing between to the two technologies really depends on your needs. Consider the following before choosing which technology to use on your next .NET web services project.

Choose WCF if:

  1. Your service needs support for multiple transport protocols such as HTTP, TCP, UDP, and custom transports.
  2. Your service needs support for multiple encodings such as TEXT, MTOM, and Binary.
  3. You need to use WSDL to  generate client proxies.
  4. Your service needs WS-* Standards such as Reliable Messaging, Transactions, and Message Security.

Choose ASP.NET Web API if:

  1. Your service is only HTTP based.
  2. Your service needs basic protocol and formats such as HTTP, Web Sockets, SSL, JQuery, JSON, and XML. ASP.NET Web API does not support higher level protocols such as Reliable Messaging or Transactions.
  3. Your service does not need to generate client proxies.
  4. Your service needs full support for REST style services.

In short, choose WCF for reliable and secure service that is accessible over multiple transports. Choose ASP.NET Web API for HTTP based services.

Happy coding!

Like this post? Share it!