TempData lagging behind
Once I included the ServiceAttribute class in my project similarly to the downloadable code, my TempData is lagging behind. This is because the TempData actually has more than 1 value in it for the Message.ascx UserControl. Therefore, it is taking the first item when it does all the if/then checks. For example, if I want to delete a Poll I will first get the warning message. If I click on the "No" button I still get the warning message instead of the informational message stating it was not deleted. If I look at TempData I see the WarningMessage and InformationMessage items in there and therefore it is selecting the WarningMessage first.
To get around this I have included some code at the end of the OnActionExecuting method in the ServiceAttribute class. I am not sure if this is the correct way to do this, but it works for me.
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// previous code
if (filterContext.Controller != null)
filterContext.Controller.TempData = null;
}
|