Share via


MvcHandler Class

Selects the controller that will handle an HTTP request.

Inheritance Hierarchy

System.Object
  System.Web.Mvc.MvcHandler

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

Syntax

'Declaration
Public Class MvcHandler _
    Implements IHttpAsyncHandler, IHttpHandler, IRequiresSessionState
public class MvcHandler : IHttpAsyncHandler, IHttpHandler, 
    IRequiresSessionState
public ref class MvcHandler : IHttpAsyncHandler, 
    IHttpHandler, IRequiresSessionState

The MvcHandler type exposes the following members.

Constructors

  Name Description
Public method MvcHandler Initializes a new instance of the MvcHandler class.

Top

Properties

  Name Description
Public propertyStatic member DisableMvcResponseHeader Gets or sets a value that indicates whether the MVC response header is disabled.
Protected property IsReusable Gets a value that indicates whether another request can use the IHttpHandler instance.
Public property RequestContext Gets the request context.

Top

Methods

  Name Description
Protected method AddVersionHeader Adds the version header by using the specified HTTP context.
Protected method BeginProcessRequest(HttpContext, AsyncCallback, Object) Called by ASP.NET to begin asynchronous request processing.
Protected method BeginProcessRequest(HttpContextBase, AsyncCallback, Object) Called by ASP.NET to begin asynchronous request processing using the base HTTP context.
Protected method EndProcessRequest Called by ASP.NET when asynchronous request processing has ended.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
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 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method ProcessRequest(HttpContext) Processes the request by using the specified HTTP request context.
Protected method ProcessRequest(HttpContextBase) Processes the request by using the specified base HTTP request context.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Fields

  Name Description
Public fieldStatic member MvcVersionHeaderName Contains the header name of the ASP.NET MVC version.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IHttpAsyncHandler.BeginProcessRequest Called by ASP.NET to begin asynchronous request processing using the base HTTP context.
Explicit interface implemetationPrivate method IHttpAsyncHandler.EndProcessRequest Called by ASP.NET when asynchronous request processing has ended.
Explicit interface implemetationPrivate property IHttpHandler.IsReusable Gets a value that indicates whether another request can use the IHttpHandler instance.
Explicit interface implemetationPrivate method IHttpHandler.ProcessRequest Enables processing of HTTP Web requests by a custom HTTP handler that implements the IHttpHandler interface.

Top

Remarks

MVC includes the following handler types:

  • MvcHandler. This handler is responsible for initiating the ASP.NET pipeline for an MVC application. It receives a Controller instance from the MVC controller factory; this controller handles further processing of the request. Note that even though MvcHandler implements IHttpHandler, it cannot be mapped as a handler (for example, to the .mvc file-name extension) because the class does not support a parameterless constructor. (Its only constructor requires a RequestContext object.)

  • MvcRouteHandler. This class implements IRouteHandler, therefore it can integrate with ASP.NET routing. The MvcRouteHandler class associates the route with an MvcHandler instance. A MvcRouteHandler instance is registered with routing when you use the MapRoute method. When the MvcRouteHandler class is invoked, the class generates an MvcHandler instance using the current RequestContext instance. It then delegates control to the new MvcHandler instance.

  • MvcHttpHandler. This handler is used to facilitate direct handler mapping without going through the routing module. This is useful if you want to map a file-name extension such as .mvc directly to an MVC handler. Internally, MvcHttpHandler performs the same tasks that ASP.NET routing ordinarily performs (going through MvcRouteHandler and MvcHandler). However, it performs these tasks as a handler instead of as a module. This handler is not typically used when the UrlRoutingModule is enabled for all requests.

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

Understanding the MVC Application Execution Process