I have a PartialView called TopPanel. This Panel is responsible for displaying error messages generated on any page in my application. To handle this, when any exception occurs on a page, I have it call an "ErrorHandler" action in the TopPanel controller. ErrorHandler updates the ViewBag with the error message and calls the Index action which just returns the partial view(for now, since im testing. I will have it call the Main Controllers Index Action later to display the whole page). My understanding is that calling the Index action will reload the view and the ErrorDiv that I have on TopPanels PartilaView will be able to display the new error message in ViewBag. However, nothing gets displayed and I'm not sure why.
Heres some code -
The ErrorHandler Action -
public ActionResult ErrorHandler(string message)
{
ViewBag.ErrorMsg = message;
return RedirectToAction("Index");
}
I've checked in the debugger, "message" does have a valid value. And ViewBag.ErrorMsg does get populated as well.
Index Action of TopPanel -
public ActionResult Index()
{
return PartialView();
}
TopPanels PartialView contains this lone which displays the error -
<div id="errorMsgBox">@ViewBag.ErrorMsg</div>
Can anyone point out what the issue is?