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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:32:59+00:00 2026-05-21T21:32:59+00:00

I’ve found a wierd scenario that prevents a bool? being posted back to the

  • 0

I’ve found a wierd scenario that prevents a bool? being posted back to the controller correctly. It’s a very specific problem so follow the steps to recreate.

The application must be deployed as a virtual folder in IIS so that instead of /Home/Test the URL is /Virtual/Home/Test.

Home Controller:

[HttpGet]
public ActionResult Test(int? temp, bool? testBool)
{
    return View(testBool);
}

/Home/Test View (Razor cshtml):

@model bool?
@{
    ViewBag.Title = "Test";
}

@using (Html.BeginForm("Test", "Home", FormMethod.Get))
{
    @Html.CheckBox("testBool", Model ?? false, new { onchange = "this.form.submit();" })
    @Html.Label(Model == true ? "True" : "False")
}

On post back the bool? doesn’t make it to the controller because of the int? before it in the parameter list. This can be solved by putting the bool? before the int? in the parameter list but obviously you shouldn’t have to do this. It also works fine if not in a Virtual folder on IIS. The same problem exists if using a POST method too although posting a bool rather than a bool? does work but isn’t necessary if not on a virtual folder so shouldn’t have to do this either.

Has anyone else experienced this and is there anything that explains why binding fails or is it just a bug in MVC3?

If it is just a bug, does anyone know what are the proper ASP.Net MVC channels for submitting bug reports?

Update:

I’ve found that if you have any number of nullable variables in the action parameters, only the first one will ever work and all others will fail to be populated. Anyone know if this is by design or a bug?

  • 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-21T21:33:00+00:00Added an answer on May 21, 2026 at 9:33 pm

    Apparently this is still an issue. Thought it would have been fixed by now. One way around this particular bug is to add this to your Application_Start method.

    ModelMetadataProviders.Current = new DataAnnotationsModelMetadataProvider();
    

    Adding that will allow nullable parameters to behave appropriately. I’m surprised this bug still exists as it was known as of RC2 in December.

    The difference between the route optional parameters in the article by haacked is that, in your example, routing isn’t the problem. In this case you’re posting (or querystring) data and that isn’t populating your nullable action parameters properly. I’ve checked the mvc3 source and don’t see why this should be a problem as debugging it it seems to work properly and stepping through the source results in the expected behavior. I’m fairly certain this hasn’t been fixed even though Scott Guthrie said it should be by now…

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.