Controller Controller Controller Class

Definition

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

public abstract class Controller : System.Web.Mvc.ControllerBase, IDisposable, System.Web.Mvc.Async.IAsyncController, System.Web.Mvc.Async.IAsyncManagerContainer, System.Web.Mvc.Filters.IAuthenticationFilter, System.Web.Mvc.IActionFilter, System.Web.Mvc.IAuthorizationFilter, System.Web.Mvc.IExceptionFilter, System.Web.Mvc.IResultFilter
type Controller = class
    inherit ControllerBase
    interface IActionFilter
    interface IAuthenticationFilter
    interface IAuthorizationFilter
    interface IDisposable
    interface IExceptionFilter
    interface IResultFilter
    interface IAsyncController
    interface IController
    interface IAsyncManagerContainer
Public MustInherit Class Controller
Inherits ControllerBase
Implements IActionFilter, IAsyncController, IAsyncManagerContainer, IAuthenticationFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, IResultFilter
Inheritance
Derived
Implements

Constructors

Controller() Controller() Controller()

Initializes a new instance of the Controller class.

Properties

ActionInvoker ActionInvoker ActionInvoker

Gets the action invoker for the controller.

AsyncManager AsyncManager AsyncManager

Provides asynchronous operations.

Binders Binders Binders

Gets or sets the binder.

ControllerContext ControllerContext ControllerContext

Gets or sets the controller context.

(Inherited from ControllerBase)
DisableAsyncSupport DisableAsyncSupport DisableAsyncSupport

Gets whether to disable the asynchronous support for the controller.

HttpContext HttpContext HttpContext

Gets HTTP-specific information about an individual HTTP request.

ModelState ModelState ModelState

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

Profile Profile Profile

Gets the HTTP context profile.

Request Request Request

Gets the HttpRequestBase object for the current HTTP request.

Resolver Resolver Resolver

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

Response Response Response

Gets the HttpResponseBase object for the current HTTP response.

RouteData RouteData RouteData

Gets the route data for the current request.

Server Server Server

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

Session Session Session

Gets the HttpSessionStateBase object for the current HTTP request.

TempData TempData TempData

Gets or sets the dictionary for temporary data.

(Inherited from ControllerBase)
TempDataProvider TempDataProvider TempDataProvider

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

Url Url Url

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

User User User

Gets the user security information for the current HTTP request.

ValidateRequest ValidateRequest ValidateRequest

Gets or sets a value that indicates whether request validation is enabled for this request.

(Inherited from ControllerBase)
ValueProvider ValueProvider ValueProvider

Gets or sets the value provider for the controller.

(Inherited from ControllerBase)
ViewBag ViewBag ViewBag

Gets the dynamic view data dictionary.

(Inherited from ControllerBase)
ViewData ViewData ViewData

Gets or sets the dictionary for view data.

(Inherited from ControllerBase)
ViewEngineCollection ViewEngineCollection ViewEngineCollection

Gets the view engine collection.

Methods

BeginExecute(RequestContext, AsyncCallback, Object) BeginExecute(RequestContext, AsyncCallback, Object) BeginExecute(RequestContext, AsyncCallback, Object)

Begins execution of the specified request context

BeginExecuteCore(AsyncCallback, Object) BeginExecuteCore(AsyncCallback, Object) BeginExecuteCore(AsyncCallback, Object)

Begins to invoke the action in the current controller context.

Content(String) Content(String) Content(String)

Creates a content result object by using a string.

Content(String, String) Content(String, String) Content(String, String)

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

Content(String, String, Encoding) Content(String, String, Encoding) Content(String, String, Encoding)

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

CreateActionInvoker() CreateActionInvoker() CreateActionInvoker()

Creates an action invoker.

CreateTempDataProvider() CreateTempDataProvider() CreateTempDataProvider()

Creates a temporary data provider.

Dispose() Dispose() Dispose()

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

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases unmanaged resources and optionally releases managed resources.

EndExecute(IAsyncResult) EndExecute(IAsyncResult) EndExecute(IAsyncResult)

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

EndExecuteCore(IAsyncResult) EndExecuteCore(IAsyncResult) EndExecuteCore(IAsyncResult)

Ends the execute core.

Execute(RequestContext) Execute(RequestContext) Execute(RequestContext)

Executes the specified request context.

(Inherited from ControllerBase)
ExecuteCore() ExecuteCore() ExecuteCore()

Invokes the action in the current controller context.

File(Byte[], String) File(Byte[], String) File(Byte[], String)

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

File(Byte[], String, String) File(Byte[], String, String) File(Byte[], String, String)

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

File(Stream, String) File(Stream, String) File(Stream, String)

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

File(Stream, String, String) File(Stream, String, String) File(Stream, String, String)

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

File(String, String) File(String, String) File(String, String)

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

File(String, String, String) File(String, String, String) File(String, String, String)

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

HandleUnknownAction(String) HandleUnknownAction(String) HandleUnknownAction(String)

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

HttpNotFound() HttpNotFound() HttpNotFound()

Returns an instance of the HttpNotFoundResult class.

HttpNotFound(String) HttpNotFound(String) HttpNotFound(String)

Returns an instance of the HttpNotFoundResult class.

Initialize(RequestContext) Initialize(RequestContext) Initialize(RequestContext)

Initializes data that might not be available when the constructor is called.

JavaScript(String) JavaScript(String) JavaScript(String)

Creates a JavaScriptResult object.

Json(Object) Json(Object) Json(Object)

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

Json(Object, JsonRequestBehavior) Json(Object, JsonRequestBehavior) Json(Object, JsonRequestBehavior)

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

Json(Object, String) Json(Object, String) Json(Object, String)

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

Json(Object, String, Encoding) Json(Object, String, Encoding) Json(Object, String, Encoding)

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

Json(Object, String, Encoding, JsonRequestBehavior) Json(Object, String, Encoding, JsonRequestBehavior) 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.

Json(Object, String, JsonRequestBehavior) Json(Object, String, JsonRequestBehavior) 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.

OnActionExecuted(ActionExecutedContext) OnActionExecuted(ActionExecutedContext) OnActionExecuted(ActionExecutedContext)

Called after the action method is invoked.

OnActionExecuting(ActionExecutingContext) OnActionExecuting(ActionExecutingContext) OnActionExecuting(ActionExecutingContext)

Called before the action method is invoked.

OnAuthentication(AuthenticationContext) OnAuthentication(AuthenticationContext) OnAuthentication(AuthenticationContext)

Called when authorization occurs.

OnAuthenticationChallenge(AuthenticationChallengeContext) OnAuthenticationChallenge(AuthenticationChallengeContext) OnAuthenticationChallenge(AuthenticationChallengeContext)

Called when authorization challenge occurs.

OnAuthorization(AuthorizationContext) OnAuthorization(AuthorizationContext) OnAuthorization(AuthorizationContext)

Called when authorization occurs.

OnException(ExceptionContext) OnException(ExceptionContext) OnException(ExceptionContext)

Called when an unhandled exception occurs in the action.

OnResultExecuted(ResultExecutedContext) OnResultExecuted(ResultExecutedContext) OnResultExecuted(ResultExecutedContext)

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

OnResultExecuting(ResultExecutingContext) OnResultExecuting(ResultExecutingContext) OnResultExecuting(ResultExecutingContext)

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

PartialView() PartialView() PartialView()

Creates a PartialViewResult object that renders a partial view.

PartialView(Object) PartialView(Object) PartialView(Object)

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

PartialView(String) PartialView(String) PartialView(String)

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

PartialView(String, Object) PartialView(String, Object) PartialView(String, Object)

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

Redirect(String) Redirect(String) Redirect(String)

Creates a RedirectResult object that redirects to the specified URL.

RedirectPermanent(String) RedirectPermanent(String) RedirectPermanent(String)

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

RedirectToAction(String) RedirectToAction(String) RedirectToAction(String)

Redirects to the specified action using the action name.

RedirectToAction(String, Object) RedirectToAction(String, Object) RedirectToAction(String, Object)

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

RedirectToAction(String, RouteValueDictionary) RedirectToAction(String, RouteValueDictionary) RedirectToAction(String, RouteValueDictionary)

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

RedirectToAction(String, String) RedirectToAction(String, String) RedirectToAction(String, String)

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

RedirectToAction(String, String, Object) RedirectToAction(String, String, Object) RedirectToAction(String, String, Object)

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

RedirectToAction(String, String, RouteValueDictionary) RedirectToAction(String, String, RouteValueDictionary) RedirectToAction(String, String, RouteValueDictionary)

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

RedirectToActionPermanent(String) RedirectToActionPermanent(String) RedirectToActionPermanent(String)

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

RedirectToActionPermanent(String, Object) RedirectToActionPermanent(String, Object) 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.

RedirectToActionPermanent(String, RouteValueDictionary) RedirectToActionPermanent(String, RouteValueDictionary) 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.

RedirectToActionPermanent(String, String) RedirectToActionPermanent(String, String) 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.

RedirectToActionPermanent(String, String, Object) RedirectToActionPermanent(String, String, Object) 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.

RedirectToActionPermanent(String, String, RouteValueDictionary) RedirectToActionPermanent(String, String, RouteValueDictionary) 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.

RedirectToRoute(Object) RedirectToRoute(Object) RedirectToRoute(Object)

Redirects to the specified route using the specified route values.

RedirectToRoute(RouteValueDictionary) RedirectToRoute(RouteValueDictionary) RedirectToRoute(RouteValueDictionary)

Redirects to the specified route using the route dictionary.

RedirectToRoute(String) RedirectToRoute(String) RedirectToRoute(String)

Redirects to the specified route using the route name.

RedirectToRoute(String, Object) RedirectToRoute(String, Object) RedirectToRoute(String, Object)

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

RedirectToRoute(String, RouteValueDictionary) RedirectToRoute(String, RouteValueDictionary) RedirectToRoute(String, RouteValueDictionary)

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

RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object) RedirectToRoutePermanent(Object)

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

RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary) RedirectToRoutePermanent(RouteValueDictionary)

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

RedirectToRoutePermanent(String) RedirectToRoutePermanent(String) RedirectToRoutePermanent(String)

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

RedirectToRoutePermanent(String, Object) RedirectToRoutePermanent(String, Object) 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.

RedirectToRoutePermanent(String, RouteValueDictionary) RedirectToRoutePermanent(String, RouteValueDictionary) 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.

TryUpdateModel<TModel>(TModel) TryUpdateModel<TModel>(TModel) TryUpdateModel<TModel>(TModel)

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

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

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

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

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

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

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

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

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

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

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

TryUpdateModel<TModel>(TModel, String, String[], String[]) TryUpdateModel<TModel>(TModel, String, String[], String[]) 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.

TryUpdateModel<TModel>(TModel, String, String[], String[], IValueProvider) TryUpdateModel<TModel>(TModel, String, String[], String[], IValueProvider) 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.

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

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

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

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

TryValidateModel(Object) TryValidateModel(Object) TryValidateModel(Object)

Validates the specified model instance.

TryValidateModel(Object, String) TryValidateModel(Object, String) TryValidateModel(Object, String)

Validates the specified model instance using an HTML prefix.

UpdateModel<TModel>(TModel) UpdateModel<TModel>(TModel) UpdateModel<TModel>(TModel)

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

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

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

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

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

UpdateModel<TModel>(TModel, String, IValueProvider) UpdateModel<TModel>(TModel, String, IValueProvider) 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.

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

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

UpdateModel<TModel>(TModel, String, String[], IValueProvider) UpdateModel<TModel>(TModel, String, String[], IValueProvider) 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.

UpdateModel<TModel>(TModel, String, String[], String[]) UpdateModel<TModel>(TModel, String, String[], String[]) 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.

UpdateModel<TModel>(TModel, String, String[], String[], IValueProvider) UpdateModel<TModel>(TModel, String, String[], String[], IValueProvider) 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.

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

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

UpdateModel<TModel>(TModel, String[], IValueProvider) UpdateModel<TModel>(TModel, String[], IValueProvider) 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.

ValidateModel(Object) ValidateModel(Object) ValidateModel(Object)

Validates the specified model instance.

ValidateModel(Object, String) ValidateModel(Object, String) ValidateModel(Object, String)

Validates the specified model instance using an HTML prefix.

View() View() View()

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

View(IView) View(IView) View(IView)

Creates a ViewResult object that renders the specified IView object.

View(IView, Object) View(IView, Object) View(IView, Object)

Creates a ViewResult object that renders the specified IView object.

View(Object) View(Object) View(Object)

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

View(String) View(String) View(String)

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

View(String, Object) View(String, Object) View(String, Object)

Creates a ViewResult object that renders the specified IView object.

View(String, String) View(String, String) View(String, String)

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

View(String, String, Object) View(String, String, Object) View(String, String, Object)

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

Explicit Interface Implementations

IActionFilter.OnActionExecuted(ActionExecutedContext) IActionFilter.OnActionExecuted(ActionExecutedContext) IActionFilter.OnActionExecuted(ActionExecutedContext)

This method calls the OnActionExecuted method.

IActionFilter.OnActionExecuting(ActionExecutingContext) IActionFilter.OnActionExecuting(ActionExecutingContext) IActionFilter.OnActionExecuting(ActionExecutingContext)

This method calls the OnActionExecuting method.

IAsyncController.BeginExecute(RequestContext, AsyncCallback, Object) IAsyncController.BeginExecute(RequestContext, AsyncCallback, Object) IAsyncController.BeginExecute(RequestContext, AsyncCallback, Object)

This method calls the BeginExecute method.

IAsyncController.EndExecute(IAsyncResult) IAsyncController.EndExecute(IAsyncResult) IAsyncController.EndExecute(IAsyncResult)

This method calls the EndExecute method.

IAuthenticationFilter.OnAuthentication(AuthenticationContext) IAuthenticationFilter.OnAuthentication(AuthenticationContext) IAuthenticationFilter.OnAuthentication(AuthenticationContext)

This method calls the OnAuthentication method.

IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext) IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext) IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext)

This method calls the OnAuthenticationChallenge method.

IAuthorizationFilter.OnAuthorization(AuthorizationContext) IAuthorizationFilter.OnAuthorization(AuthorizationContext) IAuthorizationFilter.OnAuthorization(AuthorizationContext)

This method calls the OnAuthorization method.

IController.Execute(RequestContext) IController.Execute(RequestContext) IController.Execute(RequestContext)

Executes the specified request context.

(Inherited from ControllerBase)
IExceptionFilter.OnException(ExceptionContext) IExceptionFilter.OnException(ExceptionContext) IExceptionFilter.OnException(ExceptionContext)

This method calls the OnException method.

IResultFilter.OnResultExecuted(ResultExecutedContext) IResultFilter.OnResultExecuted(ResultExecutedContext) IResultFilter.OnResultExecuted(ResultExecutedContext)

This method calls the OnResultExecuted method.

IResultFilter.OnResultExecuting(ResultExecutingContext) IResultFilter.OnResultExecuting(ResultExecutingContext) IResultFilter.OnResultExecuting(ResultExecutingContext)

This method calls the OnResultExecuting method.

Applies to