Wrox Programmer Forums
|
BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950
This is the forum to discuss the Wrox book ASP.NET MVC Website Programming Problem Design Solution by Nicholas Berardi, Al Katawazi, and Marco Bellinaso; ISBN: 9780470410950
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2010, 03:26 PM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Default 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;
}









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.