Asp.net mvc 2 storing my data between messages (junk)

I have a post method like this

[HttpPost]
public ActionResult Activatecard(ActivateCardViewModel model)

i do things, but at the end of the method I do it

ActivateCardViewModel m = new ActivateCardViewModel();
m.Currency = partner.DefaultCurrency;
m.ActivateAmountCents = "00";
return View(m);

therefore, I expected the view to be rendered using this new ActivateCardViewModel object, and 2 properties are populated (and shown in the view). (in get I do the same and it works there)

but, as you might have guessed, right now :) This is not so!

it remembers (shows) everything, starting with the placed object (model).

I hope this is by design, and someone can tell me why ....

EDIT

when I send 56 cents and I put, as shown in the code, 00 cents in a new object, it still shows 56 cents, so it looks at it, ignoring my new variable "m"

+3
2

HtmlHelpers?

ModelState , HtmlHelper, HtmlHelpers ModelState . reset - ModelState.

ModelState.Clear();
+4

@michael: TempData. TempData .

MSDN TempData http://msdn.microsoft.com/en-us/library/dd394711.aspx

+1

Source: https://habr.com/ru/post/1772896/


All Articles