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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:09:24+00:00 2026-06-15T12:09:24+00:00

`Greetings, Having problem posting multiple parameters to an mc controller method. controller… [HttpPost] public

  • 0

`Greetings,

Having problem posting multiple parameters to an mc controller method.

controller...
[HttpPost]
public ActionResult SaveSomething(SomeDomainObject domainObject, bool anOption)
{
}

Ajax Code...
function performPostData(postDataOptions,closeWindow) {
        $.ajax({ type: postDataOptions.httpVerb,
            url: postDataOptions.url,
            datatype: "json",
            traditional: true,
            data: postDataOptions.data(),
            success: function () {
                if (closeWindow) {
                    var window = $('#window').data("kendoWindow");
                    window.close();             
                }
            },
            error: function (xhr, status, error) {
                var msg = JSON.parse(xhr.responseText);
                var validator = $("#editBase").kendoValidator().data("kendoValidator"),
                status = $(".editValidationStatus");
                var err = msg.Message;
                status.text(err).addClass("invalid");
            }
        });
    }

JScript function to format data...

function GetPostData()
{
    var _domainObject={            
            prop1: 1,
            prop2: 2,
            prop3: 3                      
        };
        return JSON.stringify({ domainObject:_domainObject,anOption: true});
}

I seeing in network capture that this is the request body:

{"domainObject":{"prop1":1,"prop2":2,"Prop3":3},"anOption":true}

The controller raises the following exception:

The parameters dictionary contains a null entry for parameter 'anOption' of non-nullable type 'System.Boolean' for method 'System.Web.Mvc.ActionResult SaveSomething(Domain.Data.SomeDomainObject, Boolean)' in 'Reports.Controllers.TestController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters

I have been spinning my wheels for hours trying to get a simple domain object and another parameter of type bool to be serialized and passed to my controller. Any ideas?

  • 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-15T12:09:25+00:00Added an answer on June 15, 2026 at 12:09 pm

    Looks like you are missing the content type parameter in the jquery ajax call.
    You should explicitly set it as json, as in this piece of code:

    function performPostData(postDataOptions,closeWindow) {
        $.ajax({ type: postDataOptions.httpVerb,
            url: postDataOptions.url,
            datatype: "json",
            contentType: "application/json; charset=utf-8",
    
            ...rest of your code
    

    Otherwise it will get its default value (see http://api.jquery.com/jQuery.ajax/):

    application/x-www-form-urlencoded; charset=UTF-8

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

Sidebar

Related Questions

Greetings! I'm having a problem getting a text value of a captcha from a
Greetings, I'm having problem invoking a richTextBox from a worker thread in C#. I'm
Greetings all, I'm an AJAX newbie, and I'm having a problem with same origin
Greetings. I'm having a weird problem with jQuery on my website. I'm trying to
Greetings everyone, I'm having a very strange problem. I've created a DateTextBox which automaticly
Greetings again, I have this problem again on C but now using struct. Having
Greetings, Here's the problem I'm having. I have a page which redirects directly to
Greetings. I'm having troubles with the following legacy code. It's fine in everything except
Greetings Having an ImageField object in my Foo model as such: class Foo(models.Model): name
Greetings, I am using the official Autocomplete jquery widget and am having troubles dynamically

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.