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 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

Imagine this simple form <form action=<?php echo $_SERVER['REQUEST_URI']; ?> method=post> <fieldset> <legend>Contact Me</legend> <label
For explanation imagine a simple address. Written in a HTML paragraph with line breaks
For example, imagine a simple mutator that takes a single boolean parameter: void SetValue(const
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx.
I've never learnt JavaScript, but I imagine this is quite a simple problem. Just
I have written a VERY simple MVC application which just displays a single string
I need the most simple auction script you can imagine. I dont need categories,
The idea is very simple: Imagine a simple white page with a form with
imagine you have simple page like this: Hi everybody. when you click here new
Imagine this sample java class: class A { void addListener(Listener obj); void removeListener(Listener obj);

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.