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)

Inheritance Hierarchy

System.Object
  System.Web.Mvc.TempDataDictionary

Syntax

public class TempDataDictionary : IDictionary<string, object>, 
    ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, 
    IEnumerable
public ref class TempDataDictionary : IDictionary<String^, Object^>, 
    ICollection<KeyValuePair<String^, Object^>>, IEnumerable<KeyValuePair<String^, Object^>>, 
    IEnumerable
type TempDataDictionary = 
    class
        interface IDictionary<string, Object>
        interface ICollection<KeyValuePair<string, Object>>
        interface IEnumerable<KeyValuePair<string, Object>>
        interface IEnumerable
    end
Public Class TempDataDictionary
    Implements IDictionary(Of String, Object), ICollection(Of KeyValuePair(Of String, Object)),
    IEnumerable(Of KeyValuePair(Of String, Object)), IEnumerable

Constructors

Name Description
System_CAPS_pubmethod TempDataDictionary()

Initializes a new instance of the TempDataDictionary class.

Properties

Name Description
System_CAPS_pubproperty Count

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

System_CAPS_pubproperty Item[String]

Gets or sets the object that has the specified key.

System_CAPS_pubproperty Keys

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

System_CAPS_pubproperty Values

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

Methods

Name Description
System_CAPS_pubmethod Add(String, Object)

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

System_CAPS_pubmethod Clear()

Removes all items from the ICollection<T> instance.

System_CAPS_pubmethod ContainsKey(String)

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

System_CAPS_pubmethod ContainsValue(Object)

Determines whether the dictionary contains the specified value.

System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetEnumerator()

Gets the enumerator.

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod Keep()

Marks all keys in the dictionary for retention.

System_CAPS_pubmethod Keep(String)

Marks the specified key in the dictionary for retention.

System_CAPS_pubmethod Load(ControllerContext, ITempDataProvider)

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

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod Peek(String)

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

System_CAPS_pubmethod Remove(String)

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

System_CAPS_pubmethod Save(ControllerContext, ITempDataProvider)

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

System_CAPS_pubmethod ToString()

(Inherited from Object.)

System_CAPS_pubmethod TryGetValue(String, Object)

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

Explicit Interface Implementations

Name Description
System_CAPS_pubinterfaceSystem_CAPS_privmethod ICollection<KeyValuePair<String, Object>>.Add(KeyValuePair<String, Object>)

System_CAPS_pubinterfaceSystem_CAPS_privmethod ICollection<KeyValuePair<String, Object>>.Contains(KeyValuePair<String, Object>)

System_CAPS_pubinterfaceSystem_CAPS_privmethod ICollection<KeyValuePair<String, Object>>.CopyTo(KeyValuePair<String, Object>[], Int32)

System_CAPS_pubinterfaceSystem_CAPS_privmethod ICollection<KeyValuePair<String, Object>>.Remove(KeyValuePair<String, Object>)

System_CAPS_pubinterfaceSystem_CAPS_privmethod IEnumerable.GetEnumerator()

Returns an enumerator that can be used to iterate through a collection.

Remarks

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.

Thread Safety

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

See Also

System.Web.Mvc Namespace

Return to top