Monthly Archives: January 2013

Building real time applications for any client with Azure Mobile Services & Pusher

Azure Mobile Services is definitely one of the coolest technologies in the Azure family. One of the issues however, has been that it only has client libraries for Windows 8, iOS and Android, making it a bit more difficult for developers targeting other platforms (also web browsers!) to take advantage of its capabilities.

A while ago, I blogged about how to work around that – by using ZUMO REST API. However, you still didn’t have access to one of the nicest features of ZUMO for mobile devices – and that is push notifications. That changed recently, when ZUMO announced a partnership with Pusher, to provide push notifications for virtually any client.

Additionally, the team recently released another cool feature – scheduled tasks (cron jobs). Let’s see how you can use it all together to quickly build a realtime service.

More after the jump.

Continue Reading

Adding Request.IsLocal to ASP.NET Web API

I was recently asked how to filter out local requests in Web API. Indeed, one of the more useful things that developers got used to work with in traditional ASP.NET (and the System.Web.dll) was the ability to quickly check if a given request is a local one or not – by simply calling the IsLocal boolean property on HttpRequest.

This has been omitted from HttpRequestMessage in the new HTTP object model, around which Web API is built, but Web API still keeps track of that information under the hood, so you can easily write a simple extension method to bring back the old familiar syntax.

More after the jump.

Continue Reading

Magical Web API action selector – HTTP-verb and action name dispatching in a single controller

If you follow Web API on User Voice or track Web API issues on Codeplex, you’d probably know that one of the most popular requested features of Web API is to allow the developers to combine HTTP verb action dispatching (default one), with action-name based dispatching in a single controller.

The rationale is very obvious, and I’m pretty sure there is not a single Web API developer in the world, who hasn’t run into this problem – by not being allowed to combine these, whenever you want to create a nested resource, you need to add a new controller and manually register a funky nested route to facilitate it.

Let’s create a custom action selector to solve this.

Continue Reading

Easy ASP.NET Web API resource updates with Delta

One of the great features of the Microsoft ASP.NET WebAPI OData package (which you can grab as prerelease from Nuget, and which will soon, in next release cycle, become part of Web API core) is a little dynamic proxy object called Delta<T>.

It allows you to perform ridiculously easy mapping of properties between the model obtained from the database and the model passed by the client – thus facilitating all kinds of update scenarios your application may encounter.

Unfortunately, it will not work for you – unless you commit to ODataMediaTypeFormatter and all the extravaganza related to OData. What if you want to use the traditional API formatters, but still leverage on the power of Delta<T>?

Let’s have a look at how you can perform really smooth full (PUT) and partial (PATCH) updates of your resources in Web API.

Continue Reading

Replace JSON.NET with ServiceStack.Text in ASP.NET Web API

I recently stumbled across a comparison of JSON serialization libraries. which shows that ServiceStack.Text by far outperforms any of the competitors. Indeed, the folks down at ServiceStack have been building a lot of great stuff for the past few (4?) years to facilitate their framework.
ServiceStack.Text is available on Nuget and can be used outside of ServiceStack, within any .NET project, so why not use it with Web API, replacing the default serializer, JSON.NET?

Let’s do that.

Continue Reading

Asynchronously streaming video with ASP.NET Web API

A lot of people think that ASP.NET Web API is basically a fancy framework for building APIs – which couldn’t be further from the truth. Web API is mainly about the new .NET HTTP programming model it brings to the table – embracing HTTP to perform a whole magnitude of web related tasks; and APIs are just a small portion of that. Hopefully if you follow this blog, you have seen examples of that already, as we often wander in the unkown areas of ASP.NET Web API, beyond building “traditional” APIs.

Today, let’s go back to the HTTP programming model and use Web API to asynchronously stream videos.

More after the jump.

Continue Reading

Upcoming ASP.NET Web API events in Toronto

I’ll be holding two ASP.NET Web API presentations in Toronto this month – if you happen to be in the area, it would be an excellent chance for me to meet you, and dive into ASP.NET Web API together.

I’ll be covering a magnitude of topics – benefits of Web API, how it fits into the existing .NET landscape, how it differs from existing .NET Web technologies, consuming Web API from different clients, hosting in WPF applications, in Windows services, cross system HTTP communication, content negotiation, in-memory-hosting and many more.

The events are:
Jan 14th 6:30pmBuilding services for any client with ASP.NET Web API” (@ Markham .NET User Group).
  Registration: You can register for free here
  Address: 6031 Highway 7 (main intersection is Markham Road and Hwy #7), Markham, ON, L3P 3A7

Jan 18th 6:30pmEmbrace HTTP with ASP.NET Web API” (@ North Toronto .NET User Group)
  Registration: You can register for free here
  Address: North York Central Library, 5120 Yonge Street, Toronto, ON M2N 5N9, 2nd floor, Meeting Room 2/3

Hope to see you there!