Table of Contents

Class RouteCollectionExtensions

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Extends a System.Web.Routing.RouteCollection object for MVC routing.

public static class RouteCollectionExtensions
Inheritance
RouteCollectionExtensions
Inherited Members

Methods

GetVirtualPathForArea(RouteCollection, RequestContext, string, RouteValueDictionary)

Returns an object that contains information about the route and virtual path that are the result of generating a URL in the current area.

public static VirtualPathData GetVirtualPathForArea(this RouteCollection routes, RequestContext requestContext, string name, RouteValueDictionary values)

Parameters

routes RouteCollection

An object that contains the routes for the applications.

requestContext RequestContext

An object that encapsulates information about the requested route.

name string

The name of the route to use when information about the URL path is retrieved.

values RouteValueDictionary

An object that contains the parameters for a route.

Returns

VirtualPathData

An object that contains information about the route and virtual path that are the result of generating a URL in the current area.

GetVirtualPathForArea(RouteCollection, RequestContext, RouteValueDictionary)

Returns an object that contains information about the route and virtual path that are the result of generating a URL in the current area.

public static VirtualPathData GetVirtualPathForArea(this RouteCollection routes, RequestContext requestContext, RouteValueDictionary values)

Parameters

routes RouteCollection

An object that contains the routes for the applications.

requestContext RequestContext

An object that encapsulates information about the requested route.

values RouteValueDictionary

An object that contains the parameters for a route.

Returns

VirtualPathData

An object that contains information about the route and virtual path that are the result of generating a URL in the current area.

IgnoreRoute(RouteCollection, string)

Ignores the specified URL route for the given list of available routes.

public static void IgnoreRoute(this RouteCollection routes, string url)

Parameters

routes RouteCollection

A collection of routes for the application.

url string

The URL pattern for the route to ignore.

Exceptions

ArgumentNullException

The routes or url parameter is null.

IgnoreRoute(RouteCollection, string, object)

Ignores the specified URL route for the given list of the available routes and a list of constraints.

public static void IgnoreRoute(this RouteCollection routes, string url, object constraints)

Parameters

routes RouteCollection

A collection of routes for the application.

url string

The URL pattern for the route to ignore.

constraints object

A set of expressions that specify values for the url parameter.

Exceptions

ArgumentNullException

The routes or url parameter is null.

MapRoute(RouteCollection, string, string)

Maps the specified URL route.

public static Route MapRoute(this RouteCollection routes, string name, string url)

Parameters

routes RouteCollection

A collection of routes for the application.

name string

The name of the route to map.

url string

The URL pattern for the route.

Returns

Route

A reference to the mapped route.

Exceptions

ArgumentNullException

The routes or url parameter is null.

MapRoute(RouteCollection, string, string, object)

Maps the specified URL route and sets default route values.

public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults)

Parameters

routes RouteCollection

A collection of routes for the application.

name string

The name of the route to map.

url string

The URL pattern for the route.

defaults object

An object that contains default route values.

Returns

Route

A reference to the mapped route.

Exceptions

ArgumentNullException

The routes or url parameter is null.

MapRoute(RouteCollection, string, string, object, object)

Maps the specified URL route and sets default route values and constraints.

public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints)

Parameters

routes RouteCollection

A collection of routes for the application.

name string

The name of the route to map.

url string

The URL pattern for the route.

defaults object

An object that contains default route values.

constraints object

A set of expressions that specify values for the url parameter.

Returns

Route

A reference to the mapped route.

Exceptions

ArgumentNullException

The routes or url parameter is null.

MapRoute(RouteCollection, string, string, object, object, string[])

Maps the specified URL route and sets default route values, constraints, and namespaces.

public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)

Parameters

routes RouteCollection

A collection of routes for the application.

name string

The name of the route to map.

url string

The URL pattern for the route.

defaults object

An object that contains default route values.

constraints object

A set of expressions that specify values for the url parameter.

namespaces string[]

A set of namespaces for the application.

Returns

Route

A reference to the mapped route.

Exceptions

ArgumentNullException

The routes or url parameter is null.

MapRoute(RouteCollection, string, string, object, string[])

Maps the specified URL route and sets default route values and namespaces.

public static Route MapRoute(this RouteCollection routes, string name, string url, object defaults, string[] namespaces)

Parameters

routes RouteCollection

A collection of routes for the application.

name string

The name of the route to map.

url string

The URL pattern for the route.

defaults object

An object that contains default route values.

namespaces string[]

A set of namespaces for the application.

Returns

Route

A reference to the mapped route.

Exceptions

ArgumentNullException

The routes or url parameter is null.

MapRoute(RouteCollection, string, string, string[])

Maps the specified URL route and sets the namespaces.

public static Route MapRoute(this RouteCollection routes, string name, string url, string[] namespaces)

Parameters

routes RouteCollection

A collection of routes for the application.

name string

The name of the route to map.

url string

The URL pattern for the route.

namespaces string[]

A set of namespaces for the application.

Returns

Route

A reference to the mapped route.

Exceptions

ArgumentNullException

The routes or url parameter is null.