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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:20:08+00:00 2026-05-24T16:20:08+00:00

I have a few models in my MVC3 web app that have fields that

  • 0

I have a few models in my MVC3 web app that have fields that need to be set “behind the scenes” when a user creates or edits an object/entity.

I’m trying to figure out what the best practice is regarding these types of fields.

For example…

public class EntityA {
  public int Id { get; set; }
  public string Title { get; set; }
  ...
  [ForeignKey("User")]
  public int UpdatedBy_Id { get; set; }
  public virtual User UpdatedBy { get; set; }
}

The create and edit views for this allow the user to edit the “Title” field, but the “UpdatedBy” field needs to be set by the app when the entity is inserted or updated.

Is it best to drop a hidden field on the views and set “UpdatedBy_Id” there, or use the model property “get/set” body to do so? …or… Should this be on the HttpPost in the controller?

  • 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-24T16:20:08+00:00Added an answer on May 24, 2026 at 4:20 pm

    I’d prefer to place fields like this outside of user control. Especially if they’re integer fields a user can edit to make phony records. The choices then fall between using TempData(if session is enabled) or possibly retrieving it on the fly for the current user. If you’re not worried about the user modifying them, then I’d go with a simple hidden field or placing it in the route values for the post, allowing the framework to do the work for you.

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

Sidebar

Related Questions

I have a few models that need to have custom find conditions placed on
I have quite a few libraries and models that get loaded into a controller,
This is the scenario i have: im developing a web app that will list
I am building my first mvc3 app. A few questions I have are: 1)
I have a few models that share much of the same code. Where is
I have a few models which are not in the default cakephp format user(id,
I have a few models: 'Article, Video, BlogPost, News, Commodity'. Each are in their
I have few asynchronous tasks running and I need to wait until at least
Hi i am using django 1.2 .I my case i have few models which
I have several ASP.NET MVC 3 Web applications that have a lot of common

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.