0

Possible Duplicate:
How to retrieve JSON via ASP.Net context.Request

Im trying to parse an Json object but i dont understand where in the context.Request object i can find the actual data (in string format i guess).

This is how i pass the Json data to the server

$(function () {
    // Do your stuff here

    alert("wööööö");

    urlToHandler = 'JSonTestHandler.ashx';
    jsonData = '{ "FavoriteFood":"Pasta with butter and cheese", "FavoriteSport": "Submission Wrestling", "FavoriteGame": "Starcraft 2", "FavoriteMusic": "Hip Hop" }';
    $.ajax({
        url: urlToHandler,
        data: jsonData,
        dataType: 'json',
        type: 'POST',
        contentType: 'application/json',
        success: function (data) {
            setAutocompleteData(data.responseDateTime);
        },
        error: function (data, status, jqXHR) {
            alert('There was an error.');
        }
    }); // end $.ajax


});
4
  • What kind of asp is it mvc or old school Commented Sep 21, 2012 at 7:44
  • How are you passing the JSON object to your server side? Commented Sep 21, 2012 at 7:51
  • @Bardo I added the information to the question. Commented Sep 21, 2012 at 7:54
  • Also asked again here by same user stackoverflow.com/questions/12515426/… Commented Sep 21, 2012 at 8:27

1 Answer 1

0

Try this

string jsonInput=  new System.IO.StreamReader(context.Request.InputStream, System.Text.Encoding.UTF8).ReadToEnd();
Sign up to request clarification or add additional context in comments.

2 Comments

The Request.Params has a lot of values but no jsonData.
I have changed my answer from Request.Params["jsonData"] to above. Please check

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.