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

  • SEARCH
  • Home
  • 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 7948119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:37:50+00:00 2026-06-04T01:37:50+00:00

I searched all over the web and I think I’m correctly using JSON, I

  • 0

I searched all over the web and I think I’m correctly using JSON, I just can’t find what’s the problem with it.
I need to pass this json object as the parameter of an MVC controller action:

JSON:

{ 
"ContactId": "0",
"Fax2": "dsad",
"Phone2": "dsad",
"Tittle": "asdsa",
"Cellphone": "dsadsd", 
"Address": { "City": "kjshksdfks",
             "Country": "undefined",
             "Id": "0",
             "State": "dsadsa"}
}

The .NET object is as follows:

public class Contact
{
    public string ContactId {get; set;}
    public string Fax2 {get; set;}
    public string Phone2 {get; set;}
    public string Tittle {get; set;}
    public string Cellphone {get; set;}
    public Address ContactAddress {get; set;}
}

The nested address type is as follows:

public class Address
{
    public string City {get; set;}
    public string Country {get; set;}
    public int Id {get; set;}
    public string State {get; set;}
}

Whats wrong with my JSON?, what am i missing in order that passes clean to the controller action

The exact error is:
Invalid JSON primitive: Contact

Note: I tried using a javascript object, JSON.stringify, and toJSON()

Thanks in advance!

  • 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-06-04T01:37:52+00:00Added an answer on June 4, 2026 at 1:37 am

    Done, i share the solution:

    Since the petition is being made indicating that is of type “json” the additional types must be inside the json, otherwise the routing engine takes it as a non json object and for that reason marks that the json is not valid, so, in my case i do this:

    {
      "ContactId": "a",
      "Fax2": "b",
      "Phone2": "c",
      "Title": "d",
      "Cellphone": "e",
      "ContactAddress": {
          "Id": 22,
          "City": "a",
          "State": "b",
          "Country": "c"
        }
    },{"provider": 1}
    

    Altought its not required any additional configuration, for passing the additional parameter since were working with a JSON, in a different scenario that uses .NET objects we must specify that the controller can accept many parameters. So, for do this we must configure the controller routes:

    context.MapRoute(
        "Providers_default",
        "Catalogs/{controller}/{action}/{id1}/{id2}",
        new { controlller = "Provider", action = "Index", id = UrlParameter.Optional }
    );
    

    Here’s a link:
    http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx

    Best Regards!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched all over the web and can't seem to find documentation or even
I've searched all over the place and can't seem to find an answer for
Hy guys, I've searched all over the web and didn't find a solution to
I have searched over the web and I can't find anything to help me.
Searched all over, but haven't been able to find a solution. I need to
Okay, I have literally searched all over the web, but I didn't find what
i searched all over the web or i just don't see it. I want
I have searched all over the web with no luck of making this project
So I have searched all over the place and I can not seem to
I've searched all over and couldn't find an answer to this seemingly common question,

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.