Export (0) Print
Expand All

TempDataDictionary Class

Represents a set of data that persists only from one request to the next.

System::Object
  System.Web.Mvc::TempDataDictionary

Namespace:  System.Web.Mvc
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

public ref class TempDataDictionary : IDictionary<String^, Object^>, 
	ICollection<KeyValuePair<String^, Object^>>, IEnumerable<KeyValuePair<String^, Object^>>, 
	IEnumerable

The TempDataDictionary type exposes the following members.

  NameDescription
Public methodTempDataDictionaryInitializes a new instance of the TempDataDictionary class.
Top

  NameDescription
Public propertyCountGets the number of elements in the ICollection<T> object.
Public propertyItemGets or sets the object that has the specified key.
Public propertyKeysGets an ICollection<T> object that contains the keys of elements in the IDictionary<TKey, TValue> object.
Public propertyValuesGets the ICollection<T> object that contains the values in the IDictionary<TKey, TValue> object.
Top

  NameDescription
Public methodAddAdds an element that has the specified key and value to the IDictionary<TKey, TValue> object.
Public methodClearRemoves all items from the ICollection<T> instance.
Public methodContainsKeyDetermines whether the IDictionary<TKey, TValue> instance contains an element that has the specified key.
Public methodContainsValueDetermines whether the dictionary contains the specified value.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetEnumeratorGets the enumerator.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodKeep()Marks all keys in the dictionary for retention.
Public methodKeep(String)Marks the specified key in the dictionary for retention.
Public methodLoadLoads the specified controller context by using the specified data provider.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodPeekReturns an object that contains the element that is associated with the specified key, without marking the key for deletion.
Public methodRemoveRemoves the element that has the specified key from the IDictionary<TKey, TValue> object.
Public methodSaveSaves the specified controller context by using the specified data provider.
Public methodToString (Inherited from Object.)
Public methodTryGetValueGets the value of the element that has the specified key.
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection<KeyValuePair<String, Object>>::AddAdds the specified key/value pair to the dictionary.
Explicit interface implemetationPrivate methodICollection<KeyValuePair<String, Object>>::ContainsDetermines whether a sequence contains a specified element by using the default equality comparer.
Explicit interface implemetationPrivate methodICollection<KeyValuePair<String, Object>>::CopyToCopies a key/value pair to the specified array at the specified index.
Explicit interface implemetationPrivate methodIEnumerable::GetEnumeratorReturns an enumerator that can be used to iterate through a collection.
Explicit interface implemetationPrivate propertyICollection<KeyValuePair<String, Object>>::IsReadOnlyGets a value that indicates whether the dictionary is read-only.
Explicit interface implemetationPrivate methodICollection<KeyValuePair<String, Object>>::RemoveDeletes the specified key/value pair from the dictionary.
Top

You can use a TempDataDictionary object to pass data in the same way that you use a ViewDataDictionary object. However, the data in a TempDataDictionary object persists only from one request to the next, unless you mark one or more keys for retention by using the Keep method. If a key is marked for retention, the key is retained for the next request.

A typical use for a TempDataDictionary object is to pass data from an action method when it redirects to another action method. For example, an action method might store information about an error in the controller's TempData property (which returns a TempDataDictionary object) before it calls the RedirectToAction method. The next action method can then handle the error and render a view that displays an error message.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft