Introduction to ASP.NET Web API
blog.filipekberg.se
blog.filipekberg.se
Later on when you start using the IDE you have a MUCH better understanding of what's happening behind the scenes.
I'm not sure if anything like this book has been written for later versions of the .NET platform, as I haven't touched .NET since about 2008.
I didn't see any, but I'm no expert and I'm trying to learn.
As an alternative, you can implement your API in a different project and host it on a virtual path (e.g., /api). This solves the auth problem, but it poses difficulties under IIS. In particular, your Web.config inherits from the parent Web.config, so sections can be clobbered.
Ultimately, it's easiest to just host your app and your API in the same project. You can implement forms auth (or roll your own cookie auth) so your Ajax requests Just Work (TM) and then implement separate auth (like Basic Auth or OAuth) on just the API controllers to support real API usage.
The process to create a Web API class is identical to the process to create a ASP.NET MVC controller class, that is: - create a class - create public functions - set the route
It's nice make the controller role stand out and have its own name (Web API), however, I feel a bit disappointed if Microsoft touts this as a big feature of the next Visual Studio and .NET Framework.
Oh wait, no it doesn't. I guess you could say this is a completely new product that uses a lot of the same patterns as MVC, but ultimately does things very differently.
It's very elegant at this level. Adding additional methods requires more work, as does managing routing and the other support infrastructure in a more complex application, but it provides a great starting point.
One of the things that isn't great is that they, of necessity, have a different base class. Instead of Controller, it's ApiController. That makes sense. However, the differences pervade the entire stack, down to things like the Request and Response objects, and even AuthorizeAttribute (same class name in a different namespace with different parameters).
All in all, though, it's great. It certainly beats using WCF for simple REST APIs and it beats trying to repurpose MVC to implement an API.