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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:53:04+00:00 2026-06-08T03:53:04+00:00

I am using the JsonValueProviderFactory in an MVC2 web app to handle JSON requests

  • 0

I am using the JsonValueProviderFactory in an MVC2 web app to handle JSON requests inbound from an iOS iPad app.

I don’t want to map my JSON to a type. I just want to receive the raw JSON and pass it on to a model for processing. What signature should my controller action have to allow me to access the raw JSON being passed to my controller?

Here are the three I’ve tried so far; none of them work:

[ValidateInput(false)] // Allow dodgy chars in the JSON e.g. "<aa>"
        [HttpPost]
        //public ActionResult PushObject(FormCollection form) // no joy
        //public ActionResult PushObject(List<string> parms) // no joy
        //public ActionResult PushObject(string jsonRequest) // no joy
        {...
  • 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-08T03:53:07+00:00Added an answer on June 8, 2026 at 3:53 am

    Why are you using a JsonValueProviderFactory if you want to get the RAW JSON. The whole point of this factory is to map it to a view model (which by the way is the correct way). If you want to get the Raw stuff you could always read the Request.InputStream but that would be absolutely horrible:

    public ActionResult Do_Not_Do_This_Please_Use_ViewModels_Instead()
    {
        Request.InputStream.Position = 0;
        using (var reader = new StreamReader(Request.InputStream))
        {
            string json = reader.ReadToEnd();
            ...
        }
        ...
    }
    

    you could at least hide this crap in a model binder:

    public class RawRequestModelBinder : DefaultModelBinder
    {
        public override object  BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var request = controllerContext.HttpContext.Request;
            request.InputStream.Position = 0;
            using (var reader = new StreamReader(request.InputStream))
            {
                return reader.ReadToEnd();
            }
        }
    }
    

    and then have a controller action:

    public ActionResult Do_Not_Do_This_Please_Use_ViewModels_Instead(
        [ModelBinder(typeof(RawRequestModelBinder))] string rawJson
    )
    {
        ...
    }
    

    But of course the correct way to do this is to use a view model that will reflect the JSON structure that your iPhone will send:

    public ActionResult Foo(MyViewModel model)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using Yii, I want to delete all the rows that are not from today.
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
Using JPA, I want to select all Log objects for a specific actiontype. From
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using WPF/PRISM I want to log my messages through ILoggerFacade to my GUI (A
Using mercurial, I've run into an odd problem where a line from one committer
Using MVC2 I have an AJAX form which is posting to a bound model.
Using emacs on Ubuntu 11.10. I want to connect to a SQL Server database
Using WebViewBrush I can render web page content (it's screen shot) to e.g. Rectangle

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.