Questions tagged [model-binding]

Model Binding is a feature of ASP.NET MVC, and (from .NET 4.5) ASP.NET WebForms, that simplifies controller actions by using the request data to create strongly typed objects.

Model Binding is a feature of ASP.NET MVC, and (from .NET 4.5) ASP.NET WebForms, that simplifies controller actions by using the request data to create strongly typed objects.

2431 questions
73
votes
3 answers

ASP.NET MVC Binding to a dictionary

I'm trying to bind dictionary values within MVC. Within the action I have: model.Params = new Dictionary(); model.Params.Add("Value1", "1"); model.Params.Add("Value2", "2"); model.Params.Add("Value3", "3"); and within the view I…
user644344
  • 885
  • 1
  • 7
  • 7
65
votes
5 answers

How does MVC 4 List Model Binding work?

If I want a set of inputs in a form to bind to a List in MVC 4, I know that the following naming convention for input name attributes will work:
Eric
  • 5,842
  • 7
  • 42
  • 71
59
votes
4 answers

Polymorphic model binding

This question has been asked before in earlier versions of MVC. There is also this blog entry about a way to work around the problem. I'm wondering if MVC3 has introduced anything that might help, or if there are any other options. In a nutshell. …
Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
54
votes
7 answers

Passing UTC DateTime to Web API HttpGet Method results in local time

I'm trying to pass a UTC date as a query string parameter to a Web API method. The URL looks like /api/order?endDate=2014-04-01T00:00:00Z&zoneId=4 The signature of the method looks like [HttpGet] public object Index(int zoneId, DateTime? endDate =…
Ryan
  • 4,354
  • 2
  • 42
  • 78
54
votes
1 answer

How to pass IEnumerable list to controller in MVC including checkbox state?

I have an mvc application in which I am using a model like this: public class BlockedIPViewModel { public string IP { get; set; } public int ID { get; set; } public bool Checked { get; set; } } Now I have a View to bind a list like…
Praveen VR
  • 1,554
  • 2
  • 16
  • 34
52
votes
3 answers

How does a multiple select list work with model binding in ASP.NET MVC?

If you have a select list set to multiple in ASP.NET MVC, how does the modelbinding work? What does it return for your selected items, an array?