JSON MVC

As part of an ongoing project that I am working on, which involves a ASP .NET MVC 3 web site and a  standard .NET client, I needed a way in which I could expose a single API that would accept/return JSON objects.

I had a think about various different approaches to this, where I could use

I have used both of these before, but they do have their issues, such as needing an extra communications port to be open.

I thought to myself Now I have a web site, a nice ASP .NET MVC 3 one, so surely there is a way that I can use that for my JSON API which would serve both jQuery based web calls, and also the desktop client, which would make use of one of the many standard .NET web classes.

In the end I did just that, and have written about one approach that allowed me to create a JSON based API that is shared by both jQuery based calls and is also able to be called directly from a .NET exe.

I talk about my thoughts/end results in the following codeproject article:

http://www.codeproject.com/KB/aspnet/JSON_MVC.aspx

Advertisements

6 thoughts on “JSON MVC

  1. Brad says:

    I’m not sure I understand the “extra communication port” requirement for WCF Web API. You can simply host it in your MVC3 application and expose it via a route, can’t you?

  2. Chris says:

    Hi sacha,

    did you have a look at WCF RIAServices.JQuery (formaly known as ‘RIA/JS’)?
    Shouldn’t that be a good solution?

    http://jeffhandley.com/archive/2011/09/16/build.aspx

    http://wcf.codeplex.com/wikipage?title=RIA/JS

    • sacha says:

      Yeah I looked at that some time ago, but I did not like the way it only seemed to be wrapper around Entity Framework model really.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: