modelbinders Questions

5

Solved

I would like to write my own model binder for DateTime type. First of all I'd like to write a new attribute that I can attach to my model property like: [DateTimeFormat("d.M.yyyy")] public DateTim...
Soloist asked 1/3, 2010 at 14:52

7

Solved

Edit: Added bounty because I'm seeking an MVC3 solution (if one exists) other than this: DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; I have a read o...
Mcnalley asked 6/2, 2010 at 2:59

1

Solved

Have the method below in my model: public bool ShowShipping() { return Modalities.Scheduled.Has(Item.Modality); } But previously it was a property like this: public bool ShowShipping { get { re...
Oleaster asked 31/1, 2018 at 5:46

5

Solved

Is there an alternative for [Bind(Exclude = "Id")] (Related Question) ? Could I write a model binder?
Secularism asked 7/1, 2011 at 22:50

2

Solved

In ASP.NET MVC 3 RC2, the default ModelBinder will automatically parse the request body if the Content-Type is set to application/json. Problem is, this leaves the Request.InputStream at the end of...
Combes asked 21/12, 2010 at 4:16

6

Solved

Is it true that the default model binder in MVC 3.0 is capable of handling non-sequential indices (for both simple and complex model types)? I've come across posts that suggest it should, however i...
Milker asked 22/12, 2011 at 0:49

4

Solved

Model binding in ASP.NET MVC is great, but it follows locale settings. In my locale decimal separator is comma (','), but users use dot ('.') too, because they are lazy to switch layouts. I w...
Chargeable asked 18/1, 2013 at 14:9

3

Solved

I've been looking around the internet for an answer or example, but could not find one yet. I simply would like to change the default JSON serializer which is used to deserialize JSON while modelbi...
Teletype asked 2/6, 2014 at 13:2

3

Solved

I'm trying to POST JSON data to a Web Api method but the JSON data is not binding to the model. Here's my model: [DataContract] public class RegisterDataModel { [DataMember(IsRequired = true)] ...

3

Solved

I had a nice function that took my FormCollection (provided from the controller). Now I want to do a model bind instead and have my model binder call that function and it needs the FormCollection. ...
Custom asked 2/10, 2009 at 17:45

5

Solved

I know it could be bad to use domain models as view models. If my domain model has a property named IsAdmin and I have a Create controller action to create users, someone could alter my form and ge...
Spermatocyte asked 1/2, 2011 at 17:23

5

With ASP.net MVC is it possible to POST a form to a controller action which includes parameters not in the form, but from the URL? For example The Action method in GroupController: [AcceptVerbs...
Teofilateosinte asked 17/3, 2010 at 20:5

6

Solved

Say I have an object that gets some data from HttpPost and some from the database. I think I want to allow the ModelBinder to go to the database/repository for the that data missing from the post. ...
Photolysis asked 17/4, 2010 at 13:0

1

I am using a custom ModelBinder in an MVC 4 application, but it is invoked on a different thread than the request event handlers in global.asax, and this makes setting up a performance profiling co...
Erhard asked 2/9, 2013 at 15:57

1

Solved

Is it good approach in the model binder use the code like this: TryParseDate(result.AttemptedValue, format, out parsedDate) And then "format" is a variable with different (customer specific) da...
Rhyolite asked 10/7, 2013 at 7:59

3

For number of years I did ASP.NET web forms development I was spoiled by a proprietary library, which allowed me to do things like: UpdateToObject(ControlsCollection, obj) UpdateFromObject(Contr...
Pindaric asked 9/9, 2010 at 20:43

3

Solved

I want to be able to grab keys/values from a cookie and use that to bind a model. Rather than building a custom ModelBinder, I believe that the DefaultModelBinder works well out of the box, and th...
Alisiaalison asked 29/9, 2011 at 16:8

5

Solved

Given the following Model, public class A { public string Name { get; set; } } public class B { public string Address { get; set; } public A InstanceOfA { get; set; } } View, <%= Html.Te...
Truculent asked 18/2, 2009 at 4:29

1

Solved

I have an action method like this below. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Form newForm) { ... } I have a model with the following classes, which I'd like to load the dat...
Porter asked 19/12, 2012 at 19:53

1

Solved

Possible Duplicate: Inject a dependency into a custom model binder and using InRequestScope using Ninject I'm trying to bind an NHibernate session to a custom model binder: Since a c...
Myna asked 6/10, 2012 at 5:45

3

Solved

MVC3 comes out of the box with JsonValueProviderFactory() which is very handy for binding incoming JSON to a model. Unfortunately, I can't figure out how to setup model contracts with names that di...

2

Solved

I have the following: public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (filterContext == null) { throw new ArgumentNu...
Touber asked 9/2, 2012 at 17:1

2

Solved

I am trying to find some examples of building a custom model binder for a unique binding scenario I need to handle, but all of the articles I found were for older versions of MVC which are no longe...
Teutonic asked 26/2, 2010 at 18:30

2

I hope I'm not missing something incredibly obvious here but is there any reason why model binder is always having trouble binding a view model that inherits from a collection? Lets say I want to ...
Catalepsy asked 21/6, 2011 at 15:17

3

Solved

I'm not sure if this behavior is expected or not, but it seems that custom model binding doesn't work when the binding is assigned to an interface type. Has anyone experimented with this? public in...
Anet asked 4/6, 2010 at 0:5

© 2022 - 2024 — McMap. All rights reserved.