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

  • SEARCH
  • Home
  • 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 865431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:38:19+00:00 2026-05-15T09:38:19+00:00

It would be handy to limit the scope of a custom model binder for

  • 0

It would be handy to limit the scope of a custom model binder for just a specific controller action method or its entire controller. Hanselman wrote a sentence that implied alternative locations for custom model binder registration but never seemed to finish the thought:

You can either put this Custom Model Binder in charge of all your DateTimes by registering it in the Global.asax

Is it possible to make these registrations at a smaller scope of the controller system? If so, is there any reason to avoid doing so outside of the Global.asax MvcApplication (e.g., performance reasons)?

  • 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-15T09:38:19+00:00Added an answer on May 15, 2026 at 9:38 am

    As I was closing the tabs I opened for this question that I hadn’t reached before giving up, I found someone with an answer. You can assign a ModelBinderAttribute to your view models:

    [ModelBinder(typeof(SomeEditorModelModelBinder))]
    public class SomeEditorModel {
        // display model goes here
    }
    public class SomeEditorModelModelBinder : DefaultModelBinder {
        // custom model binder for said model goes here
    }
    

    While it wasn’t quite what I was looking for, it is even more specific than registering it for a controller or controller method.

    Update

    Thanks to Levi’s comment pointing out a much better solution. If you are consuming the object with a custom model binder in an MVC action method directly, you can simply decorate that method’s parameter with the ModelBinder property.

    public ActionResult SomeMethod([ModelBinder(typeof(SomeEditorModelBinder))]SomeEditorModel model) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having just created a SQL Agent Job I thought it would be handy to
I created a command line application. Then I realized it would be handy to
It would be exceedingly handy if I could do this: var MyObject = function(param1,
Shoes is very handy GUI tool. I would like to do a search form
Predictive typing is a handy feature on many mobile phones. How would/can you implement
I can see that the $.getScript bit of jquery would be handy once it's
When setting folds manually, it would be handy if it were possible to set
Django has two template tags with and url. It would be handy to be
I am having trouble deciding if a controller action, which is called by AJAX,
I thought it would be handy to create a mapping that would turn the

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.