Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJSON not deserializing to object with Service Framework (6.2)JSON not deserializing to object with Service Framework (6.2)
Previous
 
Next
New Post
6/21/2012 1:09 PM
 

Ok, I'm stumped...

I'm trying to use the Services Framework to retrieve/update some data.  I'm using the Kendo UI grid to pass data back to my service after updating.  I can see in Chrome that the data is being passed from the browser:

Request Payload
{"SportSeasonId":1,"SportId":1,"SportSeasonDescription":"NFL 2012-2013 Season","SeasonStartDate":"2012-09-05T04:00:00.000Z","SeasonEndDate":"2013-02-04T05:00:00.000Z","SeasonStatus":"B","PortalId":0,"KeyID":1}

The signature on my controller method is as follows:

[DnnAuthorize(AllowAnonymous = true)]
[HttpPost]
public ActionResult WsUpdateSportSeason(TwlSportSeason sportSeason)

The class TwlSportSeason has the exact same members as indicated in the JSON string above and all are set as public properties in the class.  The TwlSportSeason class itself is decorated with a [Serializable] attribute (although that doesn't appear to actually do anything) but none of the class members have any decorations.

My call does get routed properly (using the DNN IServiceRouteMapper implementation) to the controller but when I debug the controller method, I see that the sportSeason object is initialized but populated with null values.  It appears that the JSON is just not getting deserialized into my object.  This has been driving me crazy for the best part of a day now and nothing I try seems to work.

Anyone got any ideas?  

 
New Post
6/21/2012 4:59 PM
 
Aha... I finally figured it out. I made the assumption that the new Services Framework was actually built on MVC3 (which handles JSON deserialization automagically) when in fact it's built on MVC2! You know what they say about assuming.

Anyway, with that key piece of knowledge in hand, I was able to create (well, borrow) some code to create a JSON model binder (see http://stackoverflow.com/questions/4164114/posting-json-data-to-asp-net-mvc). The final step is to ensure that the new binder replaces the default binder at Application Start. Since modifying the DNN global.asax file isn't a very good idea (and in fact didn't work for me anyway) this involved creating an HTTPModule (see http://erraticdev.blogspot.com/2010/08/writing-ihttpmodule-thats-able-to.html) and registering it in the web.config.

Once this was done - it all worked the first time... onwards and upwards.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJSON not deserializing to object with Service Framework (6.2)JSON not deserializing to object with Service Framework (6.2)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out