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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:38:32+00:00 2026-05-18T02:38:32+00:00

Imagine a simple Action with a post public ActionResult Unsubscribe(string contentId) { // get

  • 0

Imagine a simple Action with a post

public ActionResult Unsubscribe(string contentId)
{
    // get db content and translate it to the UnsubscribeViewModel
    UnsubscribeViewModel model = 
        myRepository.FindUnsubscribeContentById(contentId).ToUnsubscribeViewModel();

    // pass model into the view
    return View(model);
}

[HttpPost]
public ActionResult Unsubscribe(UnsubscribeViewModel model)
{
    // let's convert into DalModel
    UnsubscribeModel m = model.ToUnsubscribeModel();

    // let's save into the db
    myRepository.UpdateUnsubscribe(m);

    // because I'm using 2 models, let's get the new ID 
    // and append to he View model
    model.FieldId = m.unsubscribe_id;

    // let's return the new model to the View
    return View(model);
}

my current problem is, even if I do a breakpoint on the return View(model) line, I DO HAVE the model.FieldId correctly assigned, but in the HTML Page, I have the original value (in this case a 0 because there was no prior ID, it’s a new record)

in the View I tried:

<%: Html.HiddenFor(x => x.FieldId) %>

and

<%: Html.Hidden("FieldId", Model.FieldId) %>

and they still have “0” as the value, like

<input type="hidden" value="0" name="FieldId" id="FieldId">

if I refresh the page, my Action fetch the new data and the value is changed to the correct id. But if I use RedirectToAction("Unsubscribe") I will loose the data and can’t pass a Success/Error message trough ViewData, I have to use RedirectToAction("Unsubscribe", new { something = msg }) and I don’t want this way.

Why is the View loading the original value instead the newly updated value from the Model?

Thank you.

  • 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-18T02:38:32+00:00Added an answer on May 18, 2026 at 2:38 am

    The problem is not in passing modified model back to the view. This happens correctly. Your issue is with the way HTML helpers work. That’s their normal behavior is by design. When binding the value of the input field they first look at POSTed values and after that in ViewData and view model. This means that you cannot modify the POSTed values in your controller action. As a workaround:

    <input type="hidden" value="<%= Model.FieldId %>" name="FieldId" id="FieldId" />
    

    I have answered this many times before and continue to answer it hoping that people will finally start noticing it.

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

Sidebar

Related Questions

I have written a VERY simple MVC application which just displays a single string
Im starting with MVC2 and i have a simple question: If i have a
Imagine a winform app, who copy updated assemblies from a source folder A to
Imagine two servers (each within an own jvm process) which communicate using some form
Imagine a web application that allows a logged in user to run a shell
Imagine a table with like a hundred of different columns in it. Imagine, then,
I would like to implement a basic versioning system in a MySQL table. Let's
I'm trying to determine the best general approach for querying against joined two tables
I'm currently playing with the Stack Overflow data dumps and am trying to construct
Hi i want to implement a copy feature so that i can right click

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.