public IActionResult Delete(int id) { var result = m_dynamicModuleManager.DeleteDynamicModuleWithId(id); if (result.HasError) { //TODO With PRG pattern, error after redirecting to index is lost, its possible to serialize it: https://andrewlock.net/post-redirect-get-using-tempdata-in-asp-net-core/ ModelState.AddModelError(result.Error.Message); return(View(nameof(Index))); } return(RedirectToAction(nameof(Index))); }