Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the default model binder in asp.net MVC

Tags:

asp.net-mvc

Is there any way I can set the default ModelBinder to one of my own?

like image 201
whatupdave Avatar asked Apr 12 '09 10:04

whatupdave


People also ask

What are model binders in ASP.NET MVC?

Model binding is a well-designed bridge between the HTTP request and the C# action methods. It makes it easy for developers to work with data on forms (views), because POST and GET is automatically transferred into a data model you specify. ASP.NET MVC uses default binders to complete this behind the scene.

Can we create custom model binder?

We can apply custom model binder using ModelBinder attribute by defining attributes on action method or model. If we are using this method (applying attribute on action method), we need to define this attribute on every action methods those want use this custom binding.

What is model binding in asp net?

ASP.NET MVC model binding allows mapping HTTP request data with a model. It is the procedure of creating . NET objects using the data sent by the browser in an HTTP request. Model binding is a well-designed bridge between the HTTP request and the C# action methods.


1 Answers

ModelBinders.Binders.DefaultBinder = new MyOwnModelBinder(); 
like image 135
Paco Avatar answered Sep 18 '22 20:09

Paco