Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6348189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:22:26+00:00 2026-05-24T21:22:26+00:00

I have read quite some blogs and stackoverflow answers on how to send a

  • 0

I have read quite some blogs and stackoverflow answers on how to send a JavaScript object to an asp.net MVC controller. But all examples I have seen so far require you to know which properties the JavaScript object will have (because they all convert the JavaScript object to a C# object).

When I was using PageMethods in asp.net webforms I could send any complex JavaScript object or array (even hierarchical data) and it would be converted to a Dictionary which I could iterate. Any chance I can do something similar in asp.net MVC?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:22:26+00:00Added an answer on May 24, 2026 at 9:22 pm

    I now found a way which works for me.

    1. I am converting my data to json and receive it as a string in my ASP.net MVC controller.
    2. Then I use the json.net library to read the data – since this library allows me to read the data without converting it to a C# (or VB) object.

    JavaScript code:

    //first include the json2 library for older browsers and jQuery
    $.post(url, {json: JSON.stringify(mydata)});
    

    Server side code:

    public void xyz(string json)
    {
        JObject j = JObject.Parse(json);
        string name = (string)j.SelectToken("Products[0].Name");
        //...
    }
    

    The good thing: it is “normal” json which means it is not some uncommon format or interface-type.

    EDIT: I found out that I don’t even need the C# json-library if I am using .net 4 – since I can convert any json string to a Dictionary with the help of the JavaScriptSerializer:

    JavaScriptSerializer jss = new JavaScriptSerializer();
    Dictionary<string, object> data = (Dictionary<string, object>) jss.Deserialize<dynamic>(json_string);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have read some topics on this, but i don't quite think it answers
I have tried to check the best practices for using asp.net mvc and quite
I have read quite a few selcet+update questions in here but cannot understand how
I have read this question but it's not quite what I was looking for.
I'm quite confused about several books in .NET that I have read. Would someone
I have heard/read the term but don't quite understand what it means. When should
I've read around quite a bit but haven't found a definitive answer. I have
There is a question that bothers me for quite some time. I have read
I read quite some articles about fragments, but I am still confused about how
I have been working on XNA for quite some time, but was asked to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.