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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:29:51+00:00 2026-06-12T10:29:51+00:00

When I try to do something like this: $.post(‘@Url.Action(PostComment)’, {Id:32,Title:=,Desc:=,}, function (data) { ….

  • 0

When I try to do something like this:

$.post('@Url.Action("PostComment")', {"Id":32,"Title":"=","Desc":"=",}, function (data) {
    ....
}

My controller receives this value in the FormCollection:

public ActionResult PostComment(FormCollection comment) {
    ....
}

Strangelly the value looks like:

","Desc":"="}

(The value is made with: JSON.stringify( { Id: 32, Title: “=”, Desc: “=” })

However, when the characters are other than “=” the object is received correctly.

How can I send a JSON object with this special character? Seems like MVC3 cannot process those values…

  • 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-12T10:29:51+00:00Added an answer on June 12, 2026 at 10:29 am

    I got a little bit confused about what are you realy trying to send, so I will describe both cases.

    Your JavaScript snippet and action method would suggest that you are sending application/x-www-form-urlencoded – in that case you should not use JSON.stringify on your data and everything should work just fine.

    But if you really want to send JSON (application/json), than first your JavaScript should be a little bit different:

    $.ajax({
        type: 'POST',
        url: '@Url.Action("PostComment")',
        data: JSON.stringify( { Id: 32, Title: '=', Desc: '=' }),
        contentType: 'application/json',
        success: function(result) {
        ...
        }
    });
    

    You should also get yourself a class for the entity (it can be also used for application/x-www-form-urlencoded data):

    public class Comment
    {
        public int Id { get; set; }
    
        public string Title { get; set; }
    
        public string Desc { get; set; }
    }
    

    Which allows you to change your action method like this (again this can be done for application/x-www-form-urlencoded data as well):

    public ActionResult PostComment(Comment comment)
    {
        ...
    }
    

    ASP.NET MVC will bind the data properly, just make sure your are sending data in right format with right content type and that JSON should be bind to the object.

    UPDATE

    There is one more scenario emerging from your comment – posting JSON as a value of a field in form. To achieve this you should start by changing your JavaScript to look more like this:

    $.post('@Url.Action("PostComment")', { jsonComment: JSON.stringify({ Id: 32, Title: '=', Desc: '=' }) }, function (data) {
        ...
    });
    

    Now the raw JSON can be accessed in one of two ways, through the FormCollection:

    [HttpPost]
    public ActionResult PostComment(FormCollection fields)
    {
        string jsonComment = fields["jsonComment"];
        ...
    }
    

    or directly by name:

    [HttpPost]
    public ActionResult PostComment(string jsonComment)
    {
        ...
    }
    

    This wrapping is needed because FromCollection can`t work with JSON directly, it is not designed for it. You need to post proper form data, but you can have JSON as a value with no issue (and you can have other simple values in that form data as well).

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

Sidebar

Related Questions

I want to do something like this... try { # Something in this function
I'm used to Java so when i try to so something like this: function
I’m getting an error when I try to do something like this below, <%
For example, I try to do something like this: - (BOOL)compare:(NSDecimal)leftOperand greaterThan:(NSDecimal)rightOperand { BOOL
I have an action that looks like this: [Post] [PopulateModelFromId] public ActionResult ChangeName( string
I use MVC2/asp.net and try to develop something like a wizard. This wizard will
I have something that looks like this: POST /o/oauth2/token HTTP/1.1 Host: accounts.google.com Content-Type: application/x-www-form-urlencoded
I want to try create something like Zend's Server Pagecache. What I want to
When I try to search something like C&A the only query I get in
I am using something like the above sample code but when i try 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.