My Model:
public class Message
{
public string text { get; set; }
public int reloads { get; set; }
}
My Controller:
[HttpPost]
public IActionResult LoadPage(Message model)
{
++model.reloads;
return View(model);
}
public IActionResult LoadPage()
{
return View();
}
And finally my view:
@if (@Model != null)
{
<h1>reloads: @Model.reloads</h1>
<p>@Model.text</p><br />
}
<form asp-action="LoadPage" method="post">
<input asp-for="text" type="text" />
<input asp-for="reloads" type="hidden" />
<input type="submit" />
</form>
I have tried so many different versions of this and it wont increment the reload-int.