Controller Class

 

Provides methods that respond to HTTP requests that are made to an ASP.NET MVC Web site.

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

Inheritance Hierarchy

System.Object
  System.Web.Mvc.ControllerBase
    System.Web.Mvc.Controller
      System.Web.Mvc.AsyncController

Syntax

public abstract class Controller : ControllerBase, IActionFilter, 
    IAuthenticationFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, 
    IResultFilter, IAsyncController, IController, IAsyncManagerContainer
public ref class Controller abstract : ControllerBase, IActionFilter, 
    IAuthenticationFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, 
    IResultFilter, IAsyncController, IController, IAsyncManagerContainer
[<AbstractClass>]
type Controller = 
    class
        inherit ControllerBase
        interface IActionFilter
        interface IAuthenticationFilter
        interface IAuthorizationFilter
        interface IDisposable
        interface IExceptionFilter
        interface IResultFilter
        interface IAsyncController
        interface IController
        interface IAsyncManagerContainer
    end
Public MustInherit Class Controller
    Inherits ControllerBase
    Implements IActionFilter, IAuthenticationFilter, IAuthorizationFilter,
    IDisposable, IExceptionFilter, IResultFilter, IAsyncController,
    IController, IAsyncManagerContainer

Constructors

Name Description
System_CAPS_protmethod Controller()

Initializes a new instance of the Controller class.

Properties

Name Description
System_CAPS_pubproperty ActionInvoker

Gets the action invoker for the controller.

System_CAPS_pubproperty AsyncManager

Provides asynchronous operations.

System_CAPS_protproperty Binders

Gets or sets the binder.

System_CAPS_pubproperty ControllerContext

Gets or sets the controller context.(Inherited from ControllerBase.)

System_CAPS_protproperty DisableAsyncSupport

Gets whether to disable the asynchronous support for the controller.

System_CAPS_pubproperty HttpContext

Gets HTTP-specific information about an individual HTTP request.

System_CAPS_pubproperty ModelState

Gets the model state dictionary object that contains the state of the model and of model-binding validation.

System_CAPS_pubproperty Profile

Gets the HTTP context profile.

System_CAPS_pubproperty Request

Gets the HttpRequestBase object for the current HTTP request.

System_CAPS_pubproperty Resolver

Represents a replaceable dependency resolver providing services. By default, it uses the P:System.Web.Mvc.DependencyResolver.CurrentCache.

System_CAPS_pubproperty Response

Gets the HttpResponseBase object for the current HTTP response.

System_CAPS_pubproperty RouteData

Gets the route data for the current request.

System_CAPS_pubproperty Server

Gets the HttpServerUtilityBase object that provides methods that are used during Web request processing.

System_CAPS_pubproperty Session

Gets the HttpSessionStateBase object for the current HTTP request.

System_CAPS_pubproperty TempData

Gets or sets the dictionary for temporary data.(Inherited from ControllerBase.)

System_CAPS_pubproperty TempDataProvider

Gets the temporary-data provider object that is used to store data for the next request.

System_CAPS_pubproperty Url

Gets the URL helper object that is used to generate URLs by using routing.

System_CAPS_pubproperty User

Gets the user security information for the current HTTP request.

System_CAPS_pubproperty ValidateRequest

Gets or sets a value that indicates whether request validation is enabled for this request.(Inherited from ControllerBase.)

System_CAPS_pubproperty ValueProvider

Gets or sets the value provider for the controller.(Inherited from ControllerBase.)

System_CAPS_pubproperty ViewBag

Gets the dynamic view data dictionary.(Inherited from ControllerBase.)

System_CAPS_pubproperty ViewData

Gets or sets the dictionary for view data.(Inherited from ControllerBase.)

System_CAPS_pubproperty ViewEngineCollection

Gets the view engine collection.

Methods

Name Description
System_CAPS_protmethod BeginExecute(RequestContext, AsyncCallback, Object)

Begins execution of the specified request context

System_CAPS_protmethod BeginExecuteCore(AsyncCallback, Object)

Begins to invoke the action in the current controller context.

System_CAPS_protmethod Content(String)

Creates a content result object by using a string.

System_CAPS_protmethod Content(String, String)

Creates a content result object by using a string and the content type.

System_CAPS_protmethod Content(String, String, Encoding)

Creates a content result object by using a string, the content type, and content encoding.

System_CAPS_protmethod CreateActionInvoker()

Creates an action invoker.

System_CAPS_protmethod CreateTempDataProvider()

Creates a temporary data provider.

System_CAPS_pubmethod Dispose()

Releases all resources that are used by the current instance of the Controller class.

System_CAPS_protmethod Dispose(Boolean)

Releases unmanaged resources and optionally releases managed resources.

System_CAPS_protmethod EndExecute(IAsyncResult)

Ends the invocation of the action in the current controller context.

System_CAPS_protmethod EndExecuteCore(IAsyncResult)

Ends the execute core.

System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Execute(RequestContext)

Executes the specified request context.(Inherited from ControllerBase.)

System_CAPS_protmethod ExecuteCore()

Invokes the action in the current controller context.(Overrides ControllerBase.ExecuteCore().)

System_CAPS_protmethod File(Byte[], String)

Creates a FileContentResult object by using the file contents and file type.

System_CAPS_protmethod File(Byte[], String, String)

Creates a FileContentResult object by using the file contents, content type, and the destination file name.

System_CAPS_protmethod File(Stream, String)

Creates a FileStreamResult object by using the Stream object and content type.

System_CAPS_protmethod File(Stream, String, String)

Creates a FileStreamResult object using the Stream object, the content type, and the target file name.

System_CAPS_protmethod File(String, String)

Creates a FilePathResult object by using the file name and the content type.

System_CAPS_protmethod File(String, String, String)

Creates a FilePathResult object by using the file name, the content type, and the file download name.

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_protmethod HandleUnknownAction(String)

Called when a request matches this controller, but no method with the specified action name is found in the controller.

System_CAPS_protmethod HttpNotFound()

Returns an instance of the HttpNotFoundResult class.

System_CAPS_protmethod HttpNotFound(String)

Returns an instance of the HttpNotFoundResult class.

System_CAPS_protmethod Initialize(RequestContext)

Initializes data that might not be available when the constructor is called.(Overrides ControllerBase.Initialize(RequestContext).)

System_CAPS_protmethod JavaScript(String)

Creates a JavaScriptResult object.

System_CAPS_protmethod Json(Object)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON).

System_CAPS_protmethod Json(Object, JsonRequestBehavior)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified JSON request behavior.

System_CAPS_protmethod Json(Object, String)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format.

System_CAPS_protmethod Json(Object, String, Encoding)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format.

System_CAPS_protmethod Json(Object, String, Encoding, JsonRequestBehavior)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the content type, content encoding, and the JSON request behavior.

System_CAPS_protmethod Json(Object, String, JsonRequestBehavior)

Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified content type and JSON request behavior.

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethod OnActionExecuted(ActionExecutedContext)

Called after the action method is invoked.

System_CAPS_protmethod OnActionExecuting(ActionExecutingContext)

Called before the action method is invoked.

System_CAPS_protmethod OnAuthentication(AuthenticationContext)

Called when authorization occurs.

System_CAPS_protmethod OnAuthenticationChallenge(AuthenticationChallengeContext)

Called when authorization challenge occurs.

System_CAPS_protmethod OnAuthorization(AuthorizationContext)

Called when authorization occurs.

System_CAPS_protmethod OnException(ExceptionContext)

Called when an unhandled exception occurs in the action.

System_CAPS_protmethod OnResultExecuted(ResultExecutedContext)

Called after the action result that is returned by an action method is executed.

System_CAPS_protmethod OnResultExecuting(ResultExecutingContext)

Called before the action result that is returned by an action method is executed.

System_CAPS_protmethod PartialView()

Creates a PartialViewResult object that renders a partial view.

System_CAPS_protmethod PartialView(Object)

Creates a PartialViewResult object that renders a partial view, by using the specified model.

System_CAPS_protmethod PartialView(String)

Creates a PartialViewResult object that renders a partial view, by using the specified view name.

System_CAPS_protmethod PartialView(String, Object)

Creates a PartialViewResult object that renders a partial view, by using the specified view name and model.

System_CAPS_protmethod Redirect(String)

Creates a RedirectResult object that redirects to the specified URL.

System_CAPS_protmethod RedirectPermanent(String)

Returns an instance of the RedirectResult class with the Permanent property set to true.

System_CAPS_protmethod RedirectToAction(String)

Redirects to the specified action using the action name.

System_CAPS_protmethod RedirectToAction(String, Object)

Redirects to the specified action using the action name and route values.

System_CAPS_protmethod RedirectToAction(String, RouteValueDictionary)

Redirects to the specified action using the action name and route dictionary.

System_CAPS_protmethod RedirectToAction(String, String)

Redirects to the specified action using the action name and controller name.

System_CAPS_protmethod RedirectToAction(String, String, Object)

Redirects to the specified action using the action name, controller name, and route dictionary.

System_CAPS_protmethod RedirectToAction(String, String, RouteValueDictionary)

Redirects to the specified action using the action name, controller name, and route values.

System_CAPS_protmethod RedirectToActionPermanent(String)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name.

System_CAPS_protmethod RedirectToActionPermanent(String, Object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, and route values.

System_CAPS_protmethod RedirectToActionPermanent(String, RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, and route values.

System_CAPS_protmethod RedirectToActionPermanent(String, String)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, and controller name.

System_CAPS_protmethod RedirectToActionPermanent(String, String, Object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

System_CAPS_protmethod RedirectToActionPermanent(String, String, RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified action name, controller name, and route values.

System_CAPS_protmethod RedirectToRoute(Object)

Redirects to the specified route using the specified route values.

System_CAPS_protmethod RedirectToRoute(RouteValueDictionary)

Redirects to the specified route using the route dictionary.

System_CAPS_protmethod RedirectToRoute(String)

Redirects to the specified route using the route name.

System_CAPS_protmethod RedirectToRoute(String, Object)

Redirects to the specified route using the route name and route values.

System_CAPS_protmethod RedirectToRoute(String, RouteValueDictionary)

Redirects to the specified route using the route name and route dictionary.

System_CAPS_protmethod RedirectToRoutePermanent(Object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route values.

System_CAPS_protmethod RedirectToRoutePermanent(RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route values.

System_CAPS_protmethod RedirectToRoutePermanent(String)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name.

System_CAPS_protmethod RedirectToRoutePermanent(String, Object)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name and route values.

System_CAPS_protmethod RedirectToRoutePermanent(String, RouteValueDictionary)

Returns an instance of the RedirectResult class with the Permanent property set to true using the specified route name and route values.

System_CAPS_pubmethod ToString()

(Inherited from Object.)

System_CAPS_protmethod TryUpdateModel<TModel>(TModel)

Updates the specified model instance using values from the controller's current value provider.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, IValueProvider)

Updates the specified model instance using values from the value provider.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String)

Updates the specified model instance using values from the controller's current value provider and a prefix.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String, IValueProvider)

Updates the specified model instance using values from the value provider and a list of properties to include.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String, String[])

Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String, String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and included properties.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String, String[], String[])

Updates the specified model instance using values from the controller's current value provider, a prefix, a list of properties to exclude, and a list of properties to include.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String, String[], String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, a list of properties to exclude , and a list of properties to include.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String[])

Updates the specified model instance using values from the controller's current value provider and included properties.

System_CAPS_protmethod TryUpdateModel<TModel>(TModel, String[], IValueProvider)

Updates the specified model instance using values from the value provider and a list of properties to include.

System_CAPS_protmethod TryValidateModel(Object)

Validates the specified model instance.

System_CAPS_protmethod TryValidateModel(Object, String)

Validates the specified model instance using an HTML prefix.

System_CAPS_protmethod UpdateModel<TModel>(TModel)

Updates the specified model instance using values from the controller's current value provider.

System_CAPS_protmethod UpdateModel<TModel>(TModel, IValueProvider)

Updates the specified model instance using values from the value provider.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String)

Updates the specified model instance using values from the controller's current value provider and a prefix.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String, IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and a list of properties to include.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String, String[])

Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String, String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and a list of properties to include.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String, String[], String[])

Updates the specified model instance using values from the controller's current value provider, a prefix, a list of properties to exclude, and a list of properties to include.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String, String[], String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, a list of properties to exclude, and a list of properties to include.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String[])

Updates the specified model instance using values from the controller object's current value provider.

System_CAPS_protmethod UpdateModel<TModel>(TModel, String[], IValueProvider)

Updates the specified model instance using values from the value provider, a prefix, and a list of properties to include.

System_CAPS_protmethod ValidateModel(Object)

Validates the specified model instance.

System_CAPS_protmethod ValidateModel(Object, String)

Validates the specified model instance using an HTML prefix.

System_CAPS_protmethod View()

Creates a ViewResult object that renders a view to the response.

System_CAPS_protmethod View(IView)

Creates a ViewResult object that renders the specified IView object.

System_CAPS_protmethod View(IView, Object)

Creates a ViewResult object that renders the specified IView object.

System_CAPS_protmethod View(Object)

Creates a ViewResult object by using the model that renders a view to the response.

System_CAPS_protmethod View(String)

Creates a ViewResult object by using the view name that renders a view.

System_CAPS_protmethod View(String, Object)

Creates a ViewResult object that renders the specified IView object.

System_CAPS_protmethod View(String, String)

Creates a ViewResult object using the view name and master-page name that renders a view to the response.

System_CAPS_protmethod View(String, String, Object)

Creates a ViewResult object using the view name, master-page name, and model that renders a view.

Explicit Interface Implementations

Name Description
System_CAPS_pubinterfaceSystem_CAPS_privmethod IAsyncController.BeginExecute(RequestContext, AsyncCallback, Object)

This method calls the BeginExecute method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IAsyncController.EndExecute(IAsyncResult)

This method calls the EndExecute method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IAuthenticationFilter.OnAuthentication(AuthenticationContext)

This method calls the OnAuthentication method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext)

This method calls the OnAuthenticationChallenge method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IActionFilter.OnActionExecuted(ActionExecutedContext)

This method calls the OnActionExecuted method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IActionFilter.OnActionExecuting(ActionExecutingContext)

This method calls the OnActionExecuting method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IAuthorizationFilter.OnAuthorization(AuthorizationContext)

This method calls the OnAuthorization method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IController.Execute(RequestContext)

Executes the specified request context.(Inherited from ControllerBase.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod IExceptionFilter.OnException(ExceptionContext)

This method calls the OnException method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IResultFilter.OnResultExecuted(ResultExecutedContext)

This method calls the OnResultExecuted method.

System_CAPS_pubinterfaceSystem_CAPS_privmethod IResultFilter.OnResultExecuting(ResultExecutingContext)

This method calls the OnResultExecuting method.

Remarks

A controller class name must end with "Controller". For example, a Product controller can be named ProductController but not Product or ProductCtrl.

The content last updated March 14, 2012

Controller action methods respond to requests that are sent to the controller. Controller action methods have the following restrictions:

  • Action methods must be public.

  • Action methods cannot be static.

  • Action methods cannot have unbounded generic type parameters. An unbounded generic type parameter has an empty parameter list. An unbounded generic type is also known as an open generic type. For information about unbounded generic type parameters, see the section "Unbounded Type Parameters" in Constraints on Type Parameters.

  • Action methods cannot be overloaded based on parameters. Action methods can be overloaded when they are disambiguated with attributes such as NonActionAttribute or AcceptVerbsAttribute.

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