Delen via


AsyncController Class

Provides the base class for asynchronous controllers.

Inheritance Hierarchy

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

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

Syntax

'Declaration
Public MustInherit Class AsyncController _
    Inherits Controller _
    Implements IAsyncManagerContainer, IAsyncController, IController
public abstract class AsyncController : Controller, 
    IAsyncManagerContainer, IAsyncController, IController
public ref class AsyncController abstract : public Controller, 
    IAsyncManagerContainer, IAsyncController, IController

The AsyncController type exposes the following members.

Constructors

  Name Description
Protected method AsyncController Initializes a new instance of the AsyncController class.

Top

Properties

  Name Description
Public property ActionInvoker Gets the action invoker for the controller. (Inherited from Controller.)
Public property AsyncManager Gets the asynchronous manager instance.
Protected property Binders Gets or sets the binder. (Inherited from Controller.)
Public property ControllerContext Gets or sets the controller context. (Inherited from ControllerBase.)
Public property HttpContext Gets HTTP-specific information about an individual HTTP request. (Inherited from Controller.)
Public property ModelState Gets the model state dictionary object that contains the state of the model and of model-binding validation. (Inherited from Controller.)
Public property Request Gets the HttpRequestBase object for the current HTTP request. (Inherited from Controller.)
Public property Response Gets the HttpResponseBase object for the current HTTP response. (Inherited from Controller.)
Public property RouteData Gets the route data for the current request. (Inherited from Controller.)
Public property Server Gets the HttpServerUtilityBase object that provides methods that are used during Web request processing. (Inherited from Controller.)
Public property Session Gets the HttpSessionStateBase object for the current HTTP request. (Inherited from Controller.)
Public property TempData Gets or sets the dictionary for temporary data. (Inherited from ControllerBase.)
Public property TempDataProvider Gets the temporary-data provider object that is used to store data for the next request. (Inherited from Controller.)
Public property Url Gets the URL helper object that is used to generate URLs by using routing. (Inherited from Controller.)
Public property User Gets the user security information for the current HTTP request. (Inherited from Controller.)
Public property ValidateRequest Gets or sets a value that indicates whether request validation is enabled for this request. (Inherited from ControllerBase.)
Public property ValueProvider Gets or sets the value provider for the controller. (Inherited from ControllerBase.)
Public property ViewData Gets or sets the dictionary for view data. (Inherited from ControllerBase.)

Top

Methods

  Name Description
Protected method BeginExecute Called by ASP.NET to initialize asynchronous request processing.
Protected method BeginExecuteCore Called by ASP.NET during initialization of asynchronous request processing.
Protected method Content(String) Creates a content result object by using a string. (Inherited from Controller.)
Protected method Content(String, String) Creates a content result object by using a string and the content type. (Inherited from Controller.)
Protected method Content(String, String, Encoding) Creates a content result object by using a string, the content type, and content encoding. (Inherited from Controller.)
Protected method CreateActionInvoker Creates an action invoker. (Overrides Controller.CreateActionInvoker().)
Protected method CreateTempDataProvider Creates a temporary data provider. (Inherited from Controller.)
Public method Dispose() Releases all resources that are used by the current instance of the Controller class. (Inherited from Controller.)
Protected method Dispose(Boolean) Releases unmanaged resources and optionally releases managed resources. (Inherited from Controller.)
Protected method EndExecute Cancels the execution of an asynchronous action method.
Protected method EndExecuteCore Called by ASP.NET when the current asynchronous action has completed.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Execute Executes the specified request context. (Inherited from ControllerBase.)
Protected method ExecuteCore Invokes the action in the current controller context. (Inherited from Controller.)
Protected method File(Byte[], String) Creates a FileContentResult object by using the file contents and file type. (Inherited from Controller.)
Protected method File(Stream, String) Creates a FileStreamResult object by using the Stream object and content type. (Inherited from Controller.)
Protected method File(String, String) Creates a FilePathResult object by using the file name and the content type. (Inherited from Controller.)
Protected method File(Byte[], String, String) Creates a FileContentResult object by using the file contents, content type, and the destination file name. (Inherited from Controller.)
Protected method File(Stream, String, String) Creates a FileStreamResult object using the Stream object, the content type, and the target file name. (Inherited from Controller.)
Protected method File(String, String, String) Creates a FilePathResult object by using the file name, the content type, and the file download name. (Inherited from Controller.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method HandleUnknownAction Called when a request matches this controller, but no method with the specified action name is found in the controller. (Inherited from Controller.)
Protected method Initialize Initializes data that might not be available when the constructor is called. (Inherited from Controller.)
Protected method JavaScript Creates a JavaScriptResult object. (Inherited from Controller.)
Protected method Json(Object) Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON). (Inherited from Controller.)
Protected method Json(Object, String) Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format. (Inherited from Controller.)
Protected method Json(Object, JsonRequestBehavior) Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format using the specified JSON request behavior. (Inherited from Controller.)
Protected method Json(Object, String, Encoding) Creates a JsonResult object that serializes the specified object to JavaScript Object Notation (JSON) format. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnActionExecuted Called after the action method is invoked. (Inherited from Controller.)
Protected method OnActionExecuting Called before the action method is invoked. (Inherited from Controller.)
Protected method OnAuthorization Called when authorization occurs. (Inherited from Controller.)
Protected method OnException Called when an unhandled exception occurs in the action. (Inherited from Controller.)
Protected method OnResultExecuted Called after the action result that is returned by an action method is executed. (Inherited from Controller.)
Protected method OnResultExecuting Called before the action result that is returned by an action method is executed. (Inherited from Controller.)
Protected method PartialView() Creates a PartialViewResult object that renders a partial view. (Inherited from Controller.)
Protected method PartialView(Object) Creates a PartialViewResult object that renders a partial view, by using the specified model. (Inherited from Controller.)
Protected method PartialView(String) Creates a PartialViewResult object that renders a partial view, by using the specified view name. (Inherited from Controller.)
Protected method PartialView(String, Object) Creates a PartialViewResult object that renders a partial view, by using the specified view name and model. (Inherited from Controller.)
Protected method Redirect Creates a RedirectResult object that redirects to the specified URL. (Inherited from Controller.)
Protected method RedirectToAction(String) Redirects to the specified action using the action name. (Inherited from Controller.)
Protected method RedirectToAction(String, Object) Redirects to the specified action using the action name and route values. (Inherited from Controller.)
Protected method RedirectToAction(String, String) Redirects to the specified action using the action name and controller name. (Inherited from Controller.)
Protected method RedirectToAction(String, RouteValueDictionary) Redirects to the specified action using the action name and route dictionary. (Inherited from Controller.)
Protected method RedirectToAction(String, String, Object) Redirects to the specified action using the action name, controller name, and route values. (Inherited from Controller.)
Protected method RedirectToAction(String, String, RouteValueDictionary) Redirects to the specified action using the action name, controller name, and route dictionary. (Inherited from Controller.)
Protected method RedirectToRoute(Object) Redirects to the specified route using the specified route values. (Inherited from Controller.)
Protected method RedirectToRoute(String) Redirects to the specified route using the route name. (Inherited from Controller.)
Protected method RedirectToRoute(RouteValueDictionary) Redirects to the specified route using the route dictionary. (Inherited from Controller.)
Protected method RedirectToRoute(String, Object) Redirects to the specified route using the route name and route values. (Inherited from Controller.)
Protected method RedirectToRoute(String, RouteValueDictionary) Redirects to the specified route using the route name and route dictionary. (Inherited from Controller.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Protected method TryUpdateModel<TModel>(TModel) Updates the specified model instance using values from the controller's current value provider. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, String) Updates the specified model instance using values from the controller's current value provider and a prefix. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, String[]) Updates the specified model instance using values from the controller's current value provider and included properties. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, IValueProvider) Updates the specified model instance using values from the value provider. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, String, String[]) Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, String, IValueProvider) Updates the specified model instance using values from the value provider and a prefix. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, String[], IValueProvider) Updates the specified model instance using values from the value provider and a list of properties to include. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method TryUpdateModel<TModel>(TModel, String, String[], IValueProvider) Updates the specified model instance using values from the value provider, a prefix, and included properties. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method TryValidateModel(Object) Validates the specified model instance. (Inherited from Controller.)
Protected method TryValidateModel(Object, String) Validates the specified model instance using an HTML prefix. (Inherited from Controller.)
Protected method UpdateModel<TModel>(TModel) Updates the specified model instance using values from the controller's current value provider. (Inherited from Controller.)
Protected method UpdateModel<TModel>(TModel, String) Updates the specified model instance using values from the controller's current value provider and a prefix. (Inherited from Controller.)
Protected method UpdateModel<TModel>(TModel, String[]) Updates the specified model instance using values from the controller object's current value provider. (Inherited from Controller.)
Protected method UpdateModel<TModel>(TModel, IValueProvider) Updates the specified model instance using values from the value provider. (Inherited from Controller.)
Protected method UpdateModel<TModel>(TModel, String, String[]) Updates the specified model instance using values from the controller's current value provider, a prefix, and included properties. (Inherited from Controller.)
Protected method UpdateModel<TModel>(TModel, String, IValueProvider) Updates the specified model instance using values from the value provider and a prefix. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method 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. (Inherited from Controller.)
Protected method ValidateModel(Object) Validates the specified model instance. (Inherited from Controller.)
Protected method ValidateModel(Object, String) Validates the specified model instance using an HTML prefix. (Inherited from Controller.)
Protected method View() Creates a ViewResult object that renders a view to the response. (Inherited from Controller.)
Protected method View(Object) Creates a ViewResult object by using the model that renders a view to the response. (Inherited from Controller.)
Protected method View(String) Creates a ViewResult object by using the view name that renders a view. (Inherited from Controller.)
Protected method View(IView) Creates a ViewResult object that renders the specified IView object. (Inherited from Controller.)
Protected method View(String, Object) Creates a ViewResult object by using the view name and model that renders a view to the response. (Inherited from Controller.)
Protected method View(String, String) Creates a ViewResult object using the view name and master-page name that renders a view to the response. (Inherited from Controller.)
Protected method View(IView, Object) Creates a ViewResult object that renders the specified IView object. (Inherited from Controller.)
Protected method View(String, String, Object) Creates a ViewResult object using the view name, master-page name, and model that renders a view. (Inherited from Controller.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IActionFilter.OnActionExecuted This API supports the MVC infrastructure and is not intended to be used directly from your code. This method calls the OnActionExecuted method. (Inherited from Controller.)
Explicit interface implemetationPrivate method IActionFilter.OnActionExecuting This API supports the MVC infrastructure and is not intended to be used directly from your code. This method calls the OnActionExecuting method. (Inherited from Controller.)
Explicit interface implemetationPrivate method IAsyncController.BeginExecute Called by ASP.NET to begin the execution of an asynchronous action method.
Explicit interface implemetationPrivate method IAsyncController.EndExecute Cancels the execution of an asynchronous action method by ASP.NET at the end of the execution of an asynchronous action method.
Explicit interface implemetationPrivate method IAuthorizationFilter.OnAuthorization This API supports the MVC infrastructure and is not intended to be used directly from your code. This method calls the OnAuthorization method. (Inherited from Controller.)
Explicit interface implemetationPrivate method IController.Execute Executes the specified request context. (Inherited from ControllerBase.)
Explicit interface implemetationPrivate method IExceptionFilter.OnException This API supports the MVC infrastructure and is not intended to be used directly from your code. This method calls the OnException method. (Inherited from Controller.)
Explicit interface implemetationPrivate method IResultFilter.OnResultExecuted This API supports the MVC infrastructure and is not intended to be used directly from your code. This method calls the OnResultExecuted method. (Inherited from Controller.)
Explicit interface implemetationPrivate method IResultFilter.OnResultExecuting This API supports the MVC infrastructure and is not intended to be used directly from your code. This method calls the OnResultExecuting method. (Inherited from Controller.)

Top

Remarks

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

Asynchronous controller action methods respond to requests that are sent to the controller. Asynchronous controller action methods must adhere to the following rules:

  • Asynchronous actions consist of a pair of action methods. The method that invokes the asynchronous process must have a name that ends with "Async". The method that is invoked when the process is finished (the completion method) must have a name that ends with ""Completed".

  • Action methods must be public.

  • Action methods cannot be static.

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

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

The following table lists the types that the completion action method for an asynchronous controller can return. The ActionAsync method can return any type, but the return type is ignored.

Return type

Control action return

void or null

The ControllerActionInvoker object returns an EmptyResult object.

ActionResult

The ControllerActionInvoker object calls the ExecuteResult method on the result.

Object (excluding ActionResult)

The result is passed to a CreateActionResult, method that creates a new ContentResult object. The Content method of the ContentResult object is set to the invariant string representation of the returned object.

Examples

A Visual Studio project with source code is available to accompany this topic: Download.

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

Reference

System.Web.Mvc Namespace

Other Resources

Using an Asynchronous Controller in ASP.NET MVC