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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:09:30+00:00 2026-06-13T19:09:30+00:00

Controller: public class HomeController : Controller { public ActionResult Index() { var myViewModel =

  • 0

Controller:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        var myViewModel = new CreateFavoriteListViewModel();
        var favoriteTypeDropdownList = new List<SelectListItem>();
        favoriteTypeDropdownList.Add(new SelectListItem { Text = "Text1", Value = "1" });
        favoriteTypeDropdownList.Add(new SelectListItem { Text = "Text2", Value = "2" });

        myViewModel.FavoriteTypeDropdownList = favoriteTypeDropdownList;
        return View(myViewModel);
    }

    [HttpPost]
    public ActionResult Post(CreateFavoriteListInputModel createFavoriteListInputModel)
    {
        return new EmptyResult();
    }
}

Models:

public class CreateFavoriteListViewModel
{
    public CreateFavoriteListInputModel CreateFavoriteListInputModel { get; set; }
    public List<SelectListItem> FavoriteTypeDropdownList { get; set; }
}

public class CreateFavoriteListInputModel
{
    [Required]
    public string ListName { get; set; }
    public int SelectedFavoriteType { get; set; }
}

View:

@model MvcApplication3.Controllers.CreateFavoriteListViewModel
<h2>title</h2>

@using (Html.BeginForm("Post", "Home", FormMethod.Post))
{
    @Html.LabelFor(x => x.CreateFavoriteListInputModel.ListName)
    @Html.TextBoxFor(x => x.CreateFavoriteListInputModel.ListName)

    @Html.LabelFor(x => x.CreateFavoriteListInputModel.SelectedFavoriteType)
    @Html.DropDownListFor(x => x.CreateFavoriteListInputModel.SelectedFavoriteType, Model.FavoriteTypeDropdownList)
    <input type="submit" value="Save" id="btnCreateList" name="btnCreateList" />
}

As you can see I use an input model with a special lambda expression. (x=>x.CreateFavoriteListInputModel.ListName).
The strange problem is that this does work on my home computer but not on my companies one (createFavoriteListInputModel = Null).
It seems there are different versions of ASP.NET MVC4 or something like that.

Maybe someone of you know since when this kind of model binding was supported by ASP.NET MVC.

Does my code work for you?

If I change the view models and the lamba expresion to i.e. x=>x.ListName everything works on both computers.

  • 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-13T19:09:31+00:00Added an answer on June 13, 2026 at 7:09 pm

    I found the problem. The problem is here:

    [HttpPost]
    public ActionResult Post(CreateFavoriteListInputModel createFavoriteListInputModel)
    {
        return new EmptyResult(); // DOES WORK
    }
    

    On my companies machine I had something like this:

    [HttpPost]
    public ActionResult Post(CreateFavoriteListInputModel inputModel)
    {
        return new EmptyResult(); // DOES NOT WORK
    }
    

    The parameter name has to be the same like the name of the complex object CreateFavoriteListInputModel (case insensitive).

    Post parameters:

    • CreateFavoriteListInputModel.ListName=TestList
    • CreateFavoriteListInputModel.SelectedFavoriteType=1
    • btnCreateList=Save

    What I don’t understand is why the parameter name matters?
    For primitive types this is clear, but for complex types I don’t get it.

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

Sidebar

Related Questions

public class HomeController : Controller { public ActionResult Index() { Task<string> t = DownloadStringTaskAsync(new
Controller: public class HomeController : Controller { Models.MakaleSitesiDBEntities entity = new Models.MakaleSitesiDBEntities(); public ActionResult
public class HomeController : Controller { public ActionResult Index() { return View(); } /*
I have the following action: public class HomeController : Controller { public ActionResult Index(int?
Consider: public class HomeController : Controller { private IDependency dependency; public HomeController(IDependency dependency) {
Have Controller: public class MyController : Controller { [HttpGet] public ActionResult MyAction(int iMode, string
Controller to get an image: public class PicturesSmallController : Controller { public ActionResult Details(int
I have this controller: public class StandingsController : Controller { public ViewResult Index(int id)
I write a controller like below: public class AccountController : Controller { public ActionResult
I have a very simple MVC app at this point: Controller: public class HomeController

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.