TempData and FlashMessage in ASP.NET MVC

We had a new requirement in a project: We need to display a message to the users after they did some kind of action, but that message needed to disappear before the next request. We tried to do this using Session, but that didn't work out very well; after all, there's another construct we can use that does exactly this kind of thing: TempData.

TempData originally (MVC1) only stored the data until the next request, but as of MVC2 it now stores the data until you read it or until the completion of the next request, whichever is first.

But, of course, I wanted our solution to be a little more flexible that just having a bunch of FlashMessage[] checks all over my views and controllers. So, I now present to you: FlashMessage.

Here's the parts.

First, there's an Enum for the types of message we can display:

public Enum FlashMessageType
{
Success,
Warning,
Error
}

Now, we want this be set on the controller files, all of them. So, let's make a ControllerBase class: