Questions tagged [defaultmodelbinder]

For questions about .NET API DefaultModelBinder Class

Useful links

101 questions
2
votes
1 answer

Asp.net MVC Model binding derived class

I've written an abstract class PaymentMethod and 2 derived classes, PaymentMethodInvoice and PaymentMethodBilling. For each of them I've written shared EditorTemplates. The GET works fine, I select my PaymentMethod and get the right form. If I POST…
mlauth
  • 151
  • 12
2
votes
1 answer

ASP.NET MVC Model Binder not working with a dictionary

Given the following view model and action using the DefaultModelBinder, it seems to ignore the dictionary, but bind all other properties correctly. Am I missing something here? Looking at the MVC source code this seems legit. Thanks public class…
amarsuperstar
  • 1,783
  • 1
  • 17
  • 22
2
votes
1 answer

will asp.net mvc model binder keep a posted array in the proper order?

so i've got an array of numbers that i'm posting to an asp.net mvc action that has a list(of integer) parameter and it all works great. my question is this: Is it safe to assume that the list(of integer) will have the numbers in the same order…
Patricia
  • 7,752
  • 4
  • 37
  • 70
2
votes
1 answer

ModelState ErrorMessage Culture Localization

ModelState Validation Culture on HttpPost Error messages from ModelState not get localized I have read these questions and they didn't solve my problem. My problem: ModelState Validation errorMessages are always in English. Localization does not…
2
votes
3 answers

how to pass another parameter from jquery ajax to mvc controller, along with form.serialize()

I use a jQuery plugin called jscroller, which uses jquery.ajax to make ajax calls. I need to pass in all parameters from a search form, and deliver them to mvc controller, and I think the best way is to put in 'data' field the following…
Tal l
  • 265
  • 1
  • 3
  • 12
2
votes
3 answers

MVC 3 empty query string parameter value is bound as an empty string rather than null

I have the following: This action: public virtual ActionResult Search(string search, string sort) { ... } Called from this url with empty query string parameters: http://myurl.com/mycontroller/search?search=&sort= Now my understanding was that as…
2
votes
4 answers

ASP.NET MVC: avoid tight coupling when binding form POST to parameter

Let's say I have an interface like: interface IThing { int Id { get; set; } string Title { get; set; } } And in ASP.NET MVC I have a form that posts to a controller action like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult…
user10789
  • 334
  • 3
  • 14
1
vote
1 answer

DefaultModelBinder not binding model (always null) even though ModelState contains all required values

I am working with the sample ASP.NET MVC 3 application. I am working on a proof of concept for an API for a project I'm working on, by sending log in requests using HttpWebRequests. I am submitting data as JSON and am using the Content Type…
Dan Joseph
  • 685
  • 1
  • 6
  • 15
1
vote
1 answer

MVC3 Form submit single input to Action with list parameter

I have a third party control that utilizes a single hidden input field to store a list of integers. This control is used throughout the site on numerous forms. The submitted value (as displayed in Fiddler) is: items=1,35,346,547 The controller…
mindlessgoods
  • 1,135
  • 1
  • 11
  • 22
1
vote
1 answer

JSON custom binder null for derived abstract class asp.net mvc

I have made a custom binder for an abstract class. The binder decides which implementation to use. It works well, but when I add a property which does not exist in the abstract class to a child class, it is always null. Here is the code for the…
semaz
  • 115
  • 7
1
vote
0 answers

Custom Model Binder to Override BindProperty

Morning/Afternoon/Evening all, I'm pretty new to working within model binders and creating a custom model binder, so some things wont be clear to me. I'm attempting to create a custom model binder in order to validate/review each string property…
Gaz
  • 11
  • 2
1
vote
2 answers

ASP.Net MVC3 Parent Child Model Binding

I have a partial template that uses a User object as a model. The user has a collection of Accounts. On this partial template I have a loop as follows. The _Account partial template is bound to the Account class @foreach (var item in…
kolhapuri
  • 1,581
  • 4
  • 20
  • 31
1
vote
1 answer

using MVC Model Binder, how to prevent binding inner complex object properties?

i have the following model public class Person { public int Id {get;set;} [Required()] public string Name {get;set;} [Required()] public Address Address {get;set;} } public class Address { public int Id {get;set;} …
Nour
  • 5,252
  • 3
  • 41
  • 66
1
vote
0 answers

Questions about Web API DefaultModelBinder Behaviour

Given, routes are set up like below For MVC : /entries/{entryID}/Children For API: /api/entries/{entryID}/Children The model I want the request to bind to is. public class Entry { public int EntryID {get;set;} public string…
1
vote
1 answer

ASP.NET model binding to base type

I have a BaseViewModel that my View Models all inherit from. public class MagazineViewModel : BaseOutputViewMode { public string TitleOfPublication { get; set; } } In my controller I use a factory method to give the corret View Model back…
Neil
  • 2,688
  • 1
  • 23
  • 32