Questions tagged [custom-model-binder]

The custom binding class needs to inherit form IModelBinder. Here we capture the current request and extract the Form fields individually. Then we can manipulate these fields any way we like.

Useful links

176 questions
1
vote
1 answer

How to chain binders in asp.net MVC 4?

I just wrote my first model binder in asp.net MVC. I started with a pure HTML form that had all the inputs with names prefixed by "fm_". public class HuggiesModel { public string fm_firstname { get; set; } public DateTime fm_duedate { get;…
Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121
1
vote
1 answer

Asp.net mvc3 filter and custom model binder execution order

In my application I have an action filter with order 0 to handle timeout (we check if the session is null. If yes, then direct the user to timeout page) which is decorated on all Controller actions. But, I was seeing an intermittent behavior wherein…
1
vote
0 answers

IModelBinder with DataAnnotation Support

We have to use a custom ModelBinder that implements IModelBinder. We cannot directly change this code at all. It currently doesn't have support for updating ModelState from the DataAnnotations of the model passed in. We want to subclass the…
drogon
  • 1,785
  • 3
  • 21
  • 34
0
votes
1 answer

Custom ModelBinder for DateTime Localization

I have a form on an ASP.NET MVC site which I've recently changed from POST to GET. However when I've done this I've realised that the DateTime parameters in the related action are now effectively using a different culture - en-US for GET, rather…
djbme
  • 143
  • 1
  • 1
  • 7
0
votes
0 answers

Model bind tag collection

Is it possible to add a model binder for something like this? public class Foo { public TagCollection Tags { get; set; } public Test() { Tags = new TagCollection(); } }
marcus
  • 9,616
  • 9
  • 58
  • 108
0
votes
1 answer

How do i create a custom model binder in ASP.NET Web Forms?

I'm using ASP.NET Web Forms and can't migrate to ASP.NET MVC right now. I love the way the MVC team implemented a custom IHttpHandler, or HttpModule (Not sure which one) that gets the JSON data passed in from an Client Side Ajax request and passes…
Orson
  • 14,981
  • 11
  • 56
  • 70
0
votes
0 answers

Attempt to create field name which already exists and is active

I have created a custom module. Show me an error when I want to enable my custom module. The error is - FieldException: Attempt to create field name windfarm_unit_count which already exists and is active. in field_create_field() (line 85 of…
0
votes
2 answers

How do I add a custom ModelBinder to a custom type inside a C# class?

I have a WarehouseDTO class with a Name field of a custom type called CustomString. I'm trying to create a custom ModelBinder to bind the type when it is passed from the front end via the controller. My controller: public async Task
0
votes
0 answers

yolov7 custom model traing

train: Scanning 'data/train/labels.cache' images and labels... 46 found, 0 missing, 0 empty, 46 corrupted: 100%|█████| 46/46 [00:00
0
votes
0 answers

ASP.NET Core Web API - Can I use [FromServices] with custom model binder to achieve [SwaggerIgnore]?

Versions: Swashbuckle 6.5, .Net 7 We need to pass environment parameters into our controller methods. Those parameters are set with custom model binders. Here is a simple example for the IP address: [Route("/api/persons")] [HttpGet] public…
M. Koch
  • 525
  • 4
  • 20
0
votes
2 answers

Exception Type: KeyError when registering a new user using a custom made register model

Whenever I try to register a new user when i receive an Exception Type: KeyError error. There seem to be something wrong with the submitted password but I don't understand the issue in depth. Can someone please explain this error to me? And perhaps…
0
votes
1 answer

What does NOT NULL constraint failed: generalpage_userregister.user_id mean and how is the issue resolved in my case?

I'm trying to create a website using Django but have an issue I've been struggling with for a few hours. Can someone explain why I recieve: NOT NULL constraint failed: generalpage_userregister.user_id error and how to resolve this issue? I suspect…
0
votes
0 answers

ASP.NET Core 6 - xUnit Test for Controller using custom IModelBinder to parse HttpRequest Query

I'm a bit lost in testing my custom modelbinder that parses a querystring. As the API is given and now must be migrated to .NET CORE, I am not able to change the syntax of the url query parameter. So I can not use the [FromQuery] attribute at the…
0
votes
1 answer

Testing If a class is being activated using WebActivator and if add a IModelBinder to ModelBinderProviders.BinderProviders.

Dear fellows from Stack Exchange. I'm trying to test if my Custom Model Binder is being added to the ModelBinderProviders.BinderProviders collection. I decided to activate this through WebActivator, to avoid messing global.asax, Everything works…
0
votes
1 answer

How to I write ModelBinder that access all fields by prefix?

For example, I like my ModelBinder to transform all "field_???" values to my single custom object. How I could do that? ValueProvider.GetValue only allows me to access by exact name, and I can't enumerate all possible fields...
Leotsarev
  • 1,040
  • 7
  • 23