Tuesday, 17 September 2013

Accessing JSON on server side (asp.net)

Accessing JSON on server side (asp.net)

I have a web app that we're still stuck in asp.net 2.5 with. We've started
using some newer technology with our front end, including loading some of
our data into JSON objects and passing them around the application using
localStorage. It's working really great.
In the future we're going to change our ASP.NET web form architecture into
ah HTML5/JQuery front and Web API back end. So we're trying to write for
that future while still being constrained to our old web form post backs
and business objects. So right now we're posting from our search form to
our search result page web form and we'll be calling a method from our
business object to grab and return search results.
The criteria object we pass in has 20 or so values and a couple of
collections (product line ID's, category ID's, etc..). So it's a slightly
complicated object. In the old form we grabbed values from the controls,
validated them, and passed them in using the asp.net controls, it was a
single form solution. Our new solution has a search form and a results
page. We're passing our values from form to form in a JSON object in
internal storage. I can't really get to that from server side so I also
stashed the values in a hidden field on the form that I can grab on the
server side when I POST to the results page (eventually we'll call an API
from the new form using ajax). So now that I can see the data, how do I
parse and work with a JSON object in the code behind of asp.net. I need to
load the 20 or so search criteria values and iterate through the ID
collections (Guid and int) to load them into the same criteria object.
This object is then passed in as the search methods parameter and search
results will come back. Not sure how to manipulate the json on the server
side.

No comments:

Post a Comment