0
我在viewbag中設置一個錯誤消息,以便在每次回發後向用戶顯示,我不希望在頁面重新加載或刷新時顯示此錯誤消息。我試圖將它設置爲null,但它仍然顯示,因爲json參數仍然包含第一次提交的值。即使頁面刷新後,asp.net mvc actionresult仍保留參數值?
[HttpPost]
[CustomAuthorize(Definitions.RoleAnalystManager, Definitions.RoleProjectManager)]
public ActionResult ExportReportAllMediaDetailsCsv(string json)
{
ViewBag.Error = null;
var serializer = new JavaScriptSerializer();
var reportParams = serializer.Deserialize<ReportAllMediaDetailsParams>(json);
var rows = uow.Items.Report_AllMediaDetails(reportParams.profileID, reportParams.organisationID, reportParams.startDate, reportParams.endDate).ToList();
if (rows.Count <= 1)
{
ViewBag.Error = "There were no results for the provided parameters, please adjust the parameters and try again.";
return View("AllMediaDetails");
}