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 8182421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:51:26+00:00 2026-06-07T00:51:26+00:00

I am trying to pass a simple JSON object to a controller using MVC3

  • 0

I am trying to pass a simple JSON object to a controller using MVC3 and JSON. The object gets passed but I loose all the properties. I see all the properties in firebug on the request but am not sure why I am loosing them on the server. Do all the properties of the object need to be set in order for the mapping to work? I am using MVC3 so the binding should be build in. What am I missing?

Class:

[Serializable]
public class StoryNote
{
    public int Id { get; set; }
    public string Note { get; set; }
    public Nullable<int> StoryCardId { get; set; }
    public string CreatedBy { get; set; }
    public Nullable<System.DateTime> CreateDate { get; set; }
    public virtual StoryCard StoryCard { get; set; }
}

JSON:

$(document).ready(function () {

    $('#newNote').click(function (e) {
        e.preventDefault();
        var storynote = {
            StoryNote: {                  
                Note: $('#Note').val(),
                StoryCardId: $('#StoryCard_Id').val(),
                CreatedBy: 'Xyz',                }
        };


        $.ajax({
            url: '@Url.Action("PostNote")',
            type: 'POST',
            data: JSON.stringify(storynote),
            dataType: 'json',                
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                $('#previousNotes').append(data.Note + '<br/>' + data.CreatedBy + '<br/><hr/>');
            },
        });
    });
});

Controller:

    [HttpPost]
    public JsonResult PostNote(StoryNote newStoryNote)
    {

        StoryNote newNote = new StoryNote { Note = newStoryNote.Note, CreatedBy = newStoryNote.CreatedBy, StoryCardId = newStoryNote.StoryCardId, CreateDate = DateTime.Now };
        db.StoryNotes.Add(newStoryNote);

        return Json(newStoryNote, JsonRequestBehavior.AllowGet);
    }
  • 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-07T00:51:28+00:00Added an answer on June 7, 2026 at 12:51 am

    You have a name mismatch in your code – parameter is named “StoryNote” in Javascript code and “newStoryNote” in Controller. Those names should be equal. I believe if you change

    var storynote = {
            StoryNote: {                  
                Note: $('#Note').val(),
                StoryCardId: $('#StoryCard_Id').val(),
                CreatedBy: 'Xyz',                }
        };
    

    to

    var storynote = {
            newStoryNote: {                  
                Note: $('#Note').val(),
                StoryCardId: $('#StoryCard_Id').val(),
                CreatedBy: 'Xyz',                }
        };
    

    then your code should work.

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

Sidebar

Related Questions

I was trying to pass tables using JSON as shown below. sample.json { title:
I'm trying to make simple script using jquery $post function to pass data to
I'm trying to pass a complex object via Windows Communication Foundation, but I get
I'm trying to pass an array to my template with a simple tag. I
I think I have got something simple wrong here. I am trying to pass
I'm trying to build a simple GAE application that would read a textbox, pass
I've been trying various configurations in order to call a simple JSON-RPC server for
I have a very weird problem while trying to pass and SQL query using
I'm trying to get a simple pass through geometry shader to work under Mac
I am trying to pass the id through reverse. But it's not working. I'm

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.