Controller Class Home
This page is specific to:.NET Framework Version:3.54.0
.NET Framework Class Library
Controller Class

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

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

'Usage

Dim instance As Controller

'Declaration

Public MustInherit Class Controller _
    Inherits ControllerBase _
    Implements IActionFilter, IAuthorizationFilter, IDisposable, IExceptionFilter,  _
    IResultFilter
Remarks

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

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 (C# Programming Guide).

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

The following table lists the types that a controller action method can return and the scenarios for which the types are returned.

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, which creates a new ContentResult object. The Content property of the ContentResult object is set to the invariant string representation of the returned object.

Inheritance Hierarchy

System..::.Object
  System..::.MarshalByRefObject
    System.Web.Mvc..::.ControllerBase
      System.Web.Mvc..::.Controller
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

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View