ASP.NET MVC API or WCF API

I am developing an ASP.NET MVC 3 application. I need this application to use the API, which I also need to implement. The API must be accessible from the actions of the ASP.NET MVC and Ajax controller. Now it's pretty easy to make an API using ASP.NET MVC, but is it possible to use it for other ASP.NET MVC website activities? I think WCF is pretty easy to use, as it is just a link to a service.

Other API users may be Windows Phone and iPhone.

Update:

Many see only the API as a place where you consume data, but what about the part where you want to execute commands or do something like adding a client or changing foo?

+7
source share
4 answers

You can check out our new WCF web API, which was announced in PDC. We recently released a big update. The WCF Web API is designed specifically to provide you access to a variety of client APIs in a clean HTTP way. It is lightweight, offers a nice configuration (no configuration files), and is also much easier to test.

You can download the bit at wcf.codeplex.com . It includes various samples, as well as a set of NuGet packages to get you started. Find webapi.all in NuGet.

+3
source

How I like it, with RESTful controller actions. You can return JSON and use your calls using JavaScript on your own website. Other websites will almost certainly understand JSON, and so they can easily use your API. It is much easier to record and test than a heavy WCF layer.

Check this question for some examples of REST frameworks for MVC:

ASP.NET MVC REST Structures

+3
source

One new way to execute data feeds is to use OData . Scott Hanselman has a great understanding of this in Creating the OData API for StackOverflow, including XML and JSON in 30 minutes .

This allows you to even throw LINQ queries in your URLs to get exactly the data you need.

+1
source

WCF JSON binding was really terrible the last time I used it. WCF also contains all kinds of crazy rules about threads and how you should use the [MessageBody] attributes for everything.

It was a real PITA for me.


I knew that I answered something like this:

What is the best way to implement RESTful architecture in .NET today?

0
source

All Articles