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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:52:46+00:00 2026-05-18T10:52:46+00:00

Update (21st Sept 2016) – Thanks to Digbyswift for commenting that this solution still

  • 0

Update (21st Sept 2016) – Thanks to Digbyswift for commenting that this solution still works in MVC5 also.

Update (30th April 2012) – Note to people stumbling across this question from searches etc – the accepted answer is not how I ended up doing this – but I left it accepted because it might have worked in some cases. My own answer contains the final solution I used, which is reusable and will apply to any project.

It’s also confirmed to work in v3 and v4 of the MVC framework.

I have the following model type (the names of the class and its properties have been changed to protect their identities):

public class MyExampleModel
{
  public string[] LongPropertyName { get; set; }
}

This property is then bound to a bunch (>150) of check boxes, where each one’s input name is of course LongPropertyName.

The form submits to url with an HTTP GET, and say the user selects three of those checkboxes – the url will have the query string ?LongPropertyName=a&LongPropertyName=b&LongPropertyName=c

Big problem then is that if I select all (or even just over half!) the checkboxes, I exceed the maximum query string length enforced by the request filter on IIS!

I do not want to extend that – so I want a way to trim down this query string (I know I can just switch to a POST – but even so I still want to minimize the amount of fluff in the data sent by the client).

What I want to do is have the LongPropertyName bound to simply ‘L’ so the query string would become ?L=a&L=b&L=c but without changing the property name in code.

The type in question already has a custom model binder (deriving from DefaultModelBinder), but it’s attached to its base class – so I don’t want to put code in there for a derived class. All the property binding is currently performed by the standard DefaultModelBinder logic, which I know uses TypeDescriptors and Property Descriptors etc from System.ComponentModel.

I was kinda hoping that there might be an attribute I could apply to the property to make this work – is there? Or should I be looking at implementing ICustomTypeDescriptor?

  • 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-18T10:52:47+00:00Added an answer on May 18, 2026 at 10:52 am

    You can use the BindAttribute to accomplish this.

    public ActionResult Submit([Bind(Prefix = "L")] string[] longPropertyName) {
    
    }
    

    Update

    Since the ‘longPropertyName’ parameter is part of the model object, and not an independent parameter of the controller action, you have a couple of other choices.

    You could keep the model and the property as independent parameters to your action and then manually merge the data together in the action method.

    public ActionResult Submit(MyModel myModel, [Bind(Prefix = "L")] string[] longPropertyName) {
        if(myModel != null) {
            myModel.LongPropertyName = longPropertyName;
        }
    }
    

    Another option would be implementing a custom Model Binder that performs the parameter value assignment (as above) manually, but that is most likely overkill. Here’s an example of one, if you’re interested: Flags Enumeration Model Binder.

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

Sidebar

Related Questions

Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE The second after I posted this question, thanks to the syntax highlighting of
UPDATE mytable SET this = 'this' AND that = 'that' WHERE MATCH (items) AGAINST
Update : I solved the decoding problem, thanks to pimvdb Follows the solution (in
UPDATE: Turns out my code works. Browser was caching previous failed response. Thanks for
UPDATE: QUESTION SOLVED! I realized that the reason for this is due to 'hoisting.'
Update: More info on this here: Is it true that one should not use
Update: This problem was also reported here, with a more detailed treatment of the
update: I mistyped 2 variables...so embarrassing. thanks everyone for the effort! sorry i find
Update: I reported this as a bug to Apple and they fixed it! All

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.