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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:14:28+00:00 2026-05-31T19:14:28+00:00

I had to for some reason use a hidden field to persist an Id

  • 0

I had to for some reason use a hidden field to persist an Id that was originally sent to my view (a ViewModel is sent to my view with this Id). I know I’m sending a valid Id value…that’s not the issue.

So for example I’m seding in a ViewModel that has a CarId. During runtime, I check and it’s a valid integer, the same integer I passed to it from the controller’s action that sent it to this view.

The issue is, since I’m not using/referencing that Id anywhere in the view’s markup via Razor, I think that’s why it’s not persisted back during postback. Because I notice that when I do refrence that field in markup, it’s included/persisted with postback.

Even though I have this in the layout, specifying to persist the entire model itself, it doesn’t persist that Id when I’m not using it in the form when it hits my Update action in the related controller:

@using (Html.BeginForm(null, null, FormMethod.Post, new { @model = Model }))

So when this posts back, I have to add this or else the Id is not persisted with the other values in the ViewModel

@Html.HiddenFor(model => model.CarId )

Anyone know what I’m missing here as in fundamentals?

  • 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-31T19:14:29+00:00Added an answer on May 31, 2026 at 7:14 pm

    Your POST action will only receive data which is actually in the form.
    It doesn’t magically get the rest of the model.

    Note also that attackers can modify all of this data.

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

Sidebar

Related Questions

So I had this working perfectly fine, but now for some reason I can't
Ok I should know the answer to this but for some reason I have
I was wondering if someone had already use this three technologies together. I know
For some reason I've always had trouble remembering the backwards/forwards compatibility guarantees made by
i already had 2008 express sql server but for some reason it came without
I had some code that constructed an object: function gridObjConst(id, itemName, itemPrice, itemListPrice, width,
we had some demands here in my job that include working with asp. We
I had some experience of android but know almost nothing of GCC Makefile. Here
I had some code that ran commands through Runtime.getRuntime.exec(String) , and it worked on
I don't know why for some reason the Excel built-in function =SUM() can't really

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.