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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:46:00+00:00 2026-06-05T02:46:00+00:00

Not a major question but definitely one that would be a nice one to

  • 0

Not a major question but definitely one that would be a nice one to see fixed.

I have, for example, a model that looks like this (not I cut out some to save reading time, i do have confirm fields etc 🙂 ):

public class NewUser
{
    [Required]
    public string Username{ get; set; }
    [Required]
    public string Password{ get; set; }

    public string Salt{ get; set; }
}

In my code after post (after validation) I create a salt that is used to one way encrypt the password, and it is very useful to have it in the model (I know I can leave it out but I would rather not).

If, on post, the user adds to their querystring &salt=blahblahblah, as soon as the page is posted back and MVC matches up the model, it assigns the value blahblahblah to my model as expected, I haven’t got a problem with this as I can always override this.

Is there any way that I can have an attribute that will make MVC not assign a value in a model to what was sent from the postback as there are some values in other models that I do not want it to have the possibility to set (I have my workarounds to reset them to what they should have been, but missing this could cause problems if someone wanted to attempt to hack in some values).

  • 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-05T02:46:03+00:00Added an answer on June 5, 2026 at 2:46 am

    You can use the BindAttribute to white/blacklist properties during the modelbinding:

    You can apply it on the Model level globally:

    [Bind(Exclude="Salt")]
    public class NewUser
    {
        [Required]
        public string Username{ get; set; }
        [Required]
        public string Password{ get; set; }
    
        public string Salt{ get; set; }
    }
    

    Or on the individual controller action level:

    public ActionResult MyAction([Bind(Exclude="Salt")] NewUser user)
    {
        //...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might not have a major usecase in projects, but I was just trying
Not sure what parallel programing means... but I have two thoughts of that Process
I have one query. Maybe it is a silly question but still I need
Internet Explorer appears to be the only major browser that does not support pushState
Not sure if this belongs here because its not technically a 'programming' question, but
What I have: QTreeView class with table data And connected QAbstractTableModel model Question :
I have worked with globalization settings in the past but not within the .NET
I apologize in advance for the rambling nature of this question, but I have
I have searched through google and SO for possible answers to this question, but
This question is geared towards MySQL, since that is what I'm using -- but

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.