Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
TempDataDictionary Class
Collapse the table of content
Expand the table of content

TempDataDictionary Class

 

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

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

System.Object
  System.Web.Mvc.TempDataDictionary

public class TempDataDictionary : IDictionary<stringobject>, 
	ICollection<KeyValuePair<stringobject>>, IEnumerable<KeyValuePair<stringobject>>, 
	IEnumerable

NameDescription
System_CAPS_pubmethodTempDataDictionary()

Initializes a new instance of the TempDataDictionary class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of elements in the ICollection<T> object.

System_CAPS_pubpropertyItem[String]

Gets or sets the object that has the specified key.

System_CAPS_pubpropertyKeys

Gets an ICollection<T> object that contains the keys of elements in the IDictionary<TKey, TValue> object.

System_CAPS_pubpropertyValues

Gets the ICollection<T> object that contains the values in the IDictionary<TKey, TValue> object.

NameDescription
System_CAPS_pubmethodAdd(String, Object)

Adds an element that has the specified key and value to the IDictionary<TKey, TValue> object.

System_CAPS_pubmethodClear()

Removes all items from the ICollection<T> instance.

System_CAPS_pubmethodContainsKey(String)

Determines whether the IDictionary<TKey, TValue> instance contains an element that has the specified key.

System_CAPS_pubmethodContainsValue(Object)

Determines whether the dictionary contains the specified value.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Gets the enumerator.

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodKeep()

Marks all keys in the dictionary for retention.

System_CAPS_pubmethodKeep(String)

Marks the specified key in the dictionary for retention.

System_CAPS_pubmethodLoad(ControllerContext, ITempDataProvider)

Loads the specified controller context by using the specified data provider.

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodPeek(String)

Returns an object that contains the element that is associated with the specified key, without marking the key for deletion.

System_CAPS_pubmethodRemove(String)

Removes the element that has the specified key from the IDictionary<TKey, TValue> object.

System_CAPS_pubmethodSave(ControllerContext, ITempDataProvider)

Saves the specified controller context by using the specified data provider.

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodTryGetValue(String, Object)

Gets the value of the element that has the specified key.

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.

Return to top
Show:
© 2015 Microsoft