Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4344756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:56:31+00:00 2026-05-21T11:56:31+00:00

I have a custom binder on Contract that verify if my logged user can

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:56:32+00:00Added an answer on May 21, 2026 at 11:56 am

    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.

    public class ContractModelBinderProvider : IModelBinderProvider
    {
        public IModelBinder GetBinder(Type modelType)
        {
              if(modelType == typeof(Contract))
                {
                     if(LoggedIn)
                     {
                           return  new LoggedInContractBinder();
                     }
                     else
                     { 
                           return new NotLoggedContractBinder(); 
                     } 
                } 
               return null;
        }
    }
    

    then you need to register it in your DependencyResolver/IOC container or add this (in the Global.asax – app start):

    ModelBinderProviders.BinderProviders.Add(new ContractModelBinderProvider());
    

    I’d think twice about having authorization logic in the model binder though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have a custom model binder that I set to the
This is my custom model binder. I have my breakpoint set at BindModel but
Background I have a custom collection that is binded to the datagridview this.datagridview.DataSource =
I have a custom model binder with public override object BindModel(controllerContext, bindingContext) that checks
So I have one custom model binder that inherits from DefaultModelBinder, where I am
Let's say that you have a Model that looks kind of like this: public
I would like to create a custom action filter attribute that adds a value
I have created a custom Model Binder that inherits from DefaultModelBinder, and overriding the
I have a custom model binder that takes a comma separated list and cleans
I'm using the MVC 2 RC. I have a custom model binder that used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.