One last improvement to touch on in this first preview 4
post is some improvements being made on the Controller class that allow you to
more easily unit test the TempData collection. The TempData property
allows you to store data that you want to persist for a future request from a
user. It has the semantic of only lasting one future request (after which
it is removed). It is typically used for MVC scenarios where you want to
perform a client-side redirect to change the URL in the browser, and want a
simple way to store scratch data.
With previous ASP.NET MVC Previews you had to mock objects
in order to test the TempData collection. With Preview 4 you no longer
need to mock or setup anything. You can now add and verify objects within
the Controller's TempData collection directly within your unit tests (for
example: populate a controller's TempData property before calling its action
method, or verify that the action updated the TempData after the action
returned). The actual storage semantics of the TempData collection is now
encapsulated within a separate TempDataProvider property.