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 7739813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:36:56+00:00 2026-06-01T08:36:56+00:00

In MVC3 (.Net) it is possible to set a Bind Attribute on a parameter

  • 0

In MVC3 (.Net) it is possible to set a Bind Attribute on a parameter Type in the method signature for a Controller method:

[HttpPost]
public ActionResult Edit([Bind(Exclude = "Name")]User user)
{
   ...
}

I have written some Custom ModelBinders. It would be nice to be able to affect their behavior based on attributes set on a parameter Type, like so:

[HttpPost]
public ActionResult Edit([CustomModelBinderSettings(DoCustomThing = "True")]User user)
{
   ...
}

However, I can’t seem to find a way to recover the attribute data. Is this possible?


Edit

I am trying to access the AttributeData from within a custom ModelBinder. In the example below “settings” is always null

public class TestBinder : DefaultModelBinder {
        public override object BindModel(
            ControllerContext controllerContext, 
            ModelBindingContext bindingContext) {

            //Try and get attribute from ModelType
            var settings = (CustomModelBinderSettingsAttribute) 
                TypeDescriptor.GetAttributes(bindingContext.ModelType)[typeof(CustomModelBinderSettingsAttribute)];

            ...

Thanks for any help.

  • 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-06-01T08:36:57+00:00Added an answer on June 1, 2026 at 8:36 am

    Answer: not possible 🙁

    I stepped through the MVC source code, and eventually found that the ControllorActionInvoker class explicitly accesses the bind attribute from the Action Method parameters, and sets them on a property of the bindingContext. Without overriding or rewriting large parts of the MVC infrastructure, it is not possible for attributes added to Action Parameters to be accessed from a ModelBinder.

    However, it is possible to retrieve attributes set on a ViewModel using the code illustrated in LukLeds post:

    var attr = ("GetTypeDescriptor(controllerContext, bindingContext).GetAttributes()[typeof(BindAttribute)];
    

    Alas, that is not what I set out to do in this case, but it will have to do for now.

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

Sidebar

Related Questions

Using an MVC3 .net controller on the back-end, I am performing an HttpPost to
In ASP.NET MVC3 C#, I want to have an action with this signature: public
In ASP.NET MVC3 I'm trying to set the css class that the validation error
With ASP .NET MVC3. In my controller I have this portion of code MasterMindDnetEntities
I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON
In a .NET MVC3 Razor webapplication, how is it possible to use an EditorTemplate
I have asp.net MVC3 app where validations are done by adding validation attribute in
My MVC3/.Net service is receiving some arguments as a JSONified Javascript array, and I'd
ASP.Net MVC3 is cool and all but I have this question more out of
In ASP.NET MVC3 projects, is it faster, more secure, to use Entity Framework (with

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.