I have a custom binder on Contract that verify if my logged user can view this contract and if the contract exist. I would like to have an other binder that verify if the contract exist and and if the token is good since the user does not need to be logged in.
Is it possible to have 2 binders on the same object? How do I do this?
UPDATE:
I’ve checked the source you can’t have two custom model binders to one type. I got confused with value providers.
You basically have two options, one is to create one large model binder (which I think is the better option).
another option is to create a model binder provider that returns a modelbinder for the specific needs.
then you need to register it in your DependencyResolver/IOC container or add this (in the Global.asax – app start):
I’d think twice about having authorization logic in the model binder though.