I am trying to show the value of ViewBag on my .cshtml page, but the value is always empty. Below is my code:
public async Task<IActionResult> DateCalc( int? department)
{
ViewBag.DestroyCount = 4; // docDestroyed;
return RedirectToAction(nameof(Index));
}
This is what I have in my Index.cshtml :
<div class="card">
<form asp-action="DateCalc" enctype="multipart/form-data">
<h5 class="card-header">Documents destroyed by section</h5>
<div class="card-body">
<div class="left">
<label>Select Department(s)</label>
@Html.DropDownList("department", (IEnumerable
<SelectListItem>)ViewBag.department, new{@class="form-control"})
</div>
<div></div>
<br /><br />
<input type="submit" value="submit" class="btn btn-primary" />
<p class="card-text">Documents Destroyed by Section: </p>@Html.Label((string)ViewBag.DestroyCount)
</div>
</form>
</div>
When I click on submit button, I want "Documents Destroyed by Section:" to display 4, but it does not display anything.
This is the line where I am trying to display DestroyCount after clicking on submit button:
@Html.Label((string)ViewBag.DestroyCount)
Any help will be appreciated.

