Recently I’ve been really enjoying myself with ASP.NET Web API. It is a tremendous beast, and with it’s self-hosting capabilities, it’s suitable as an HTTP-channeled-communication not only for ASP.NET websites, but also for any other .NET applications. In this post, I’m gonna try to show you the outcome of my weekend mash up – a peer-to-peer WPF chat application (clients connect directly to each other), fueled by ASP.NET Web API.
More after the jump.
What are we gonna do
So, as mentioned, we’ll try to build a chat application with WPF. It’s gonna be targeted for .NET 4.5 (possible to refactor it into .NET 4 easily as well), make use of of ASP.NET Web Api self-host, and allow us to communicate smoothly over the network through HTTP. Heck, we might even have to ditch Live and Skype by the end of this article.
With ASP.NET Web Api self-host, we can turn any C# product into a web server. What this means, is that each of our chat apps (or “clients”) will essentially be web servers, listening to incoming HTTP requests on a certain port. The idea is simple – if we have two chat “clients” out there in the network, and each of them is a web server with IP address and a port to which they listen – they can easily communicate between each other in a P2P way. We are going to use POST requests as a way to transport messages between the clients.
Getting started
We’ll start off with a normal WPF project, target it to .NET 4.5 and get the necessary self host packagaes from Nuget. To do that, go to Nuget and grab AspNetWebApi.SelfHost. If you do it from VS, it will automaticall get all dependencies as well. If not, you need the Core as well.
Read more: Strath Web
QR:
1 comments:
Wow that was odd. I just wrote an incredibly long comment but
after I clicked submit my comment didn't show up. Grrrr... well I'm
not writing all that over again. Anyway, just wanted to say great blog!
Also visit my webpage ... Create Your Own Website
Post a Comment