Questions tagged [defaultmodelbinder]

For questions about .NET API DefaultModelBinder Class

Useful links

101 questions
0
votes
0 answers

I am getting exception on a post request logged in stackify but not able to find cause of the error

Following is the exception stackify shows me on dashboard: ERROR The string was not recognized as a valid DateTime. There is an unknown word starting at index 0. System.FormatException: The string was not recognized as a valid DateTime. There is an…
Pankaj Kaushik
  • 127
  • 2
  • 11
0
votes
1 answer

dynamic model and ModelState

I have an Action like this: Update([Bind(Prefix = "CurrentModel")] dynamic edited) but when I use dynamic the ModelState.IsValid always returns true so it seems like there is no validation on the dynamic object? If not, how can I solve this?
marcus
  • 9,616
  • 9
  • 58
  • 108
0
votes
4 answers

ASP.NET MVC ModelBinder bug: Binding request variable "id" to Model's property "Id"

I am using MVC 3 final RTM. Given This route: context.MapRoute( "Blog_Posts", "Blog/Posts/{id}/{slug}", new { controller = "Posts", action = "Index", slug = UrlParameter.Optional } ); And on a post's page, e.g. /blog/posts/2/some-slug I…
kamranicus
  • 4,207
  • 2
  • 39
  • 57
0
votes
0 answers

Add Controls Dynamically in ASP .NET Core

I've tried to follow the answer by Darin Dimitrov on this post: How to create controls dynamically in MVC 3 based on an XML file. But in ASP .NET Core (Specifically ASP .NET Core 2) there is no DefaultModelBinder so I have to modify the Custom Model…
0
votes
1 answer

How to bind properly with partial views w/o having to send in entire Model

I like to take sections of my view and break them out in to multiple partial views, and I like to only pass in the part of the model that partial view is interested in. Generally I like to put a model specifically for the partial as a property on…
BVernon
  • 3,205
  • 5
  • 28
  • 64
0
votes
0 answers

C# DefaultModelBinder does not bind property of type "dynamic"

I have been trying to figure this one out for the past 2 days... My main model contains a property of type "dynamic" and looks like this: public class WGTTestModel { private dynamic _oProp3 = null; public WGTTestModel() { } …
Tarek J.
  • 21
  • 5
0
votes
1 answer

asp.net mvc default model binder for model that has inheritance

I have a form that I binding to that has the following structure: public class Status { public List ABCAttachments_Files { get; set; } } public class Attachment { public string Id { get; set; } } public class ABCAttachment :…
amurra
  • 15,221
  • 4
  • 70
  • 87
0
votes
0 answers

Fluentvalidation with Custom Indexed Collection

Recently I've been working on a decently complex UI in which I've had to adjust the default collection binding to use a 1 based collection instead of 0 based which ends up with inputs like the following when using Html.InputFor():
0
votes
1 answer

Found property which wasn't bound from response body (form data) to model MVC, default model binder

I send post request and get in response body form data: 0[family]=Marco&0[name]=Polo&0[age]=66&1[family]=Family&0[name]=Name&0[age]=22 var formData = "0[family]=Marco&0[name]=Polo&0[age]=66&1[family]=Family&0[name]=Name&0[age]=22"; var data =…
Elena
  • 125
  • 1
  • 9
0
votes
3 answers

Setting a value before the submit doesn't send it to the controller

I have a view with multiples forms, each one submit should submit a hidden field with a specific value and all of the share the same model. From my controller I set the value before rendering the view, but that value I will need it for one of the…
0
votes
4 answers

DateTime.Parse not working on an MVC custom binder

I'm getting a DateTime from an implicit binding at an Action in a .NET MVC web application. The problem is that i'm getting the date in format "MM/dd/yyyy" while i'm sending it through a query string with Ajax in format "dd/MM/yyyy". I know this is…
MorgoZ
  • 2,012
  • 5
  • 27
  • 54
0
votes
2 answers

ASP.NET MVC5 Model Binder - Null when binding collection of collections

I have researched all over the net but hopefully here someone can help me. I have following ViewModel classes: public class PersonEditViewModel { public Person Person { get; set; } public List Interests { get; set;…
Rax
  • 29
  • 4
0
votes
1 answer

Should I unit test the model returned by DefaultModelBinder?

I'm having some trouble unit testing the model returned by DefaultModelBinder. I want to feed in a fake form collection and check the model that it returns to make sure model properties are being bound properly. In my research, I'm not turning up…
Byron Sommardahl
  • 12,743
  • 15
  • 74
  • 131
0
votes
1 answer

NullReferenceException when testing DefaultModelBinder

I'm developing a project using BDD/TDD techniques and I'm trying my best to stay the course. A problem I just ran into is unit testing the DefaultModelBinder. I'm using mspec to write my tests. I have a class like this that I want to bind…
Byron Sommardahl
  • 12,743
  • 15
  • 74
  • 131
0
votes
1 answer

ASP.MVC 4 DefaultModelBinder fails on empty string binding to List

So if you post empty string to a controller like this and try to bind it to a List very strange stuff occurs Does anybody faced this issue? Why it adds default int value to a list?