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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:49:04+00:00 2026-05-18T06:49:04+00:00

For now, I just want to use HTTP POST to send json to asp.net

  • 0

For now, I just want to use HTTP POST to send json to asp.net mvc2 controller.

Since the JSON is actually a list of JSON objects, and each of them has different fields & length, so it hard for me to make up a input model.

So I want to know is there a way for me to post JSON without model/ajax to a controller in ASP.NET MVC2?

  • 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-18T06:49:04+00:00Added an answer on May 18, 2026 at 6:49 am

    Building on @Brian’s answer, we have done exactly this. Keep in mind this is Jquery 1.4.2

    This is broken out a bit and could be simplified, but it is using callbacks instead of full on posts. It was initially used for filtering results real time and reloading the first page of them back into the same area.

    First, we have the button/link/whatever on the page. This is going to call out javascript to build the json data.

    <input type="button" alt="Update" onclick="doStuff();" />
    

    Then, we have the doStuff() function. In this case, refinements is a collection of json objects.

    function doStuff() {
    
            var refinements = GetRefinementSelections();
            var profileId = '<%= Model.Profile.ProfileId %>';
    
            var startDate = $('#SearchbyDateFrom').val();
            var endDate = $('#SearchbyDateTo').val();
    
            var jsonData = JSON.stringify(
                { 
                    "ProfileId" : profileId,
                    "RefinementGroups": refinements,
                    "StartDate": startDate,
                    "EndDate": endDate
                });
    
                $('#jsonData').val(jsonData);
                $('#update-button').click();
        }
    

    Next, we have an ajax form with a hidden field inside that doStuff() puts our data into. This could be a regular old form as well.

    <% using (Ajax.BeginForm("MyAction", "MyController", new { },
           new AjaxOptions { },
           new { id = "filteredResultsForm" }))
       {  %>
        <input type="submit" id="update-button" style="display:none;" />
        <%= Html.Hidden("jsonData")%>
    <% } %>
    

    So, the click is called on this button, which causes the callback to the server. Here’s our action in the controller. JsonSerializer is part of Newtonsoft.Json

    public ActionResult MyAction(string jsonData)
        {
            JsonSerializer serializer = new JsonSerializer();
    
            StringReader sr = new StringReader(jsonData);
            Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);
    
            JsonRequest jsonRequest = (JsonRequest)serializer.Deserialize(reader, typeof(JsonRequest));
    
            //do work with object
    
            return View();
        }
    

    JsonRequest needs to be a class object, and all properties, sub classes and their properties, and so on and so forth need to be serializable for this approach to work. Despite having a fluid set of data being returned (as a collection of json objects), and without actually seeing what that data looks like, I am fairly certain you could devise some sort of class structure to support your data.

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

Sidebar

Related Questions

Use case: I've just entered insert mode, and typed some text. Now I want
I've created a custom view class and right now just want to draw an
i am done with my iphone application.Now i just want to make a binary
I just want the errors, and nothing else, to be printed out for now.
I've just got my Flash Builder 4 and now I want to create a
I just set up a simple virtual server with Debian netinst. Now I want
I have just created a GIT on a folder. I now want to add
I've just created a new view based application, and now I want to set
I have just download the .deb and installed it. It works. Now i want
I put a TCP server and client code in PIC controller. Now just wanted

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.