Table of Contents

Class OutputCacheAttribute

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Represents an attribute that is used to mark an action method whose output will be cached.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class OutputCacheAttribute : ActionFilterAttribute, IMvcFilter, IActionFilter, IResultFilter, IExceptionFilter
Inheritance
OutputCacheAttribute
Implements
Inherited Members

Constructors

OutputCacheAttribute()

Initializes a new instance of the OutputCacheAttribute class.

public OutputCacheAttribute()

Properties

CacheProfile

Gets or sets the cache profile name.

public string CacheProfile { get; set; }

Property Value

string

The cache profile name.

ChildActionCache

Gets or sets the child action cache.

public static ObjectCache ChildActionCache { get; set; }

Property Value

ObjectCache

The child action cache.

Duration

Gets or sets the cache duration, in seconds.

public int Duration { get; set; }

Property Value

int

The cache duration.

Location

Gets or sets the location.

public OutputCacheLocation Location { get; set; }

Property Value

OutputCacheLocation

The location.

NoStore

Gets or sets a value that indicates whether to store the cache.

public bool NoStore { get; set; }

Property Value

bool

true if the cache should be stored; otherwise, false.

SqlDependency

Gets or sets the SQL dependency.

public string SqlDependency { get; set; }

Property Value

string

The SQL dependency.

VaryByContentEncoding

Gets or sets the vary-by-content encoding.

public string VaryByContentEncoding { get; set; }

Property Value

string

The vary-by-content encoding.

VaryByCustom

Gets or sets the vary-by-custom value.

public string VaryByCustom { get; set; }

Property Value

string

The vary-by-custom value.

VaryByHeader

Gets or sets the vary-by-header value.

public string VaryByHeader { get; set; }

Property Value

string

The vary-by-header value.

VaryByParam

Gets or sets the vary-by-param value.

public string VaryByParam { get; set; }

Property Value

string

The vary-by-param value.

Methods

IsChildActionCacheActive(ControllerContext)

Returns a value that indicates whether a child action cache is active.

public static bool IsChildActionCacheActive(ControllerContext controllerContext)

Parameters

controllerContext ControllerContext

The controller context.

Returns

bool

true if the child action cache is active; otherwise, false.

OnActionExecuted(ActionExecutedContext)

This method is an implementation of OnActionExecuted(ActionExecutedContext) and supports the ASP.NET MVC infrastructure. It is not intended to be used directly from your code.

public override void OnActionExecuted(ActionExecutedContext filterContext)

Parameters

filterContext ActionExecutedContext

The filter context.

OnActionExecuting(ActionExecutingContext)

This method is an implementation of OnActionExecuting(ActionExecutingContext) and supports the ASP.NET MVC infrastructure. It is not intended to be used directly from your code.

public override void OnActionExecuting(ActionExecutingContext filterContext)

Parameters

filterContext ActionExecutingContext

The filter context.

OnException(ExceptionContext)

This method is an implementation of OnException(ExceptionContext) and supports the ASP.NET MVC infrastructure. It is not intended to be used directly from your code.

public void OnException(ExceptionContext filterContext)

Parameters

filterContext ExceptionContext

The filter context.

OnResultExecuted(ResultExecutedContext)

This method is an implementation of OnResultExecuted(ResultExecutedContext) and supports the ASP.NET MVC infrastructure. It is not intended to be used directly from your code.

public override void OnResultExecuted(ResultExecutedContext filterContext)

Parameters

filterContext ResultExecutedContext

The filter context.

OnResultExecuting(ResultExecutingContext)

Called before the action result executes.

public override void OnResultExecuting(ResultExecutingContext filterContext)

Parameters

filterContext ResultExecutingContext

The filter context, which encapsulates information for using AuthorizeAttribute.

Exceptions

ArgumentNullException

The filterContext parameter is null.