Export (0) Print
Expand All

RouteCollectionExtensions.MapRoute Method (RouteCollection, String, String, Object, String())

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

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

'Declaration
<ExtensionAttribute> _
Public Shared Function MapRoute ( _
	routes As RouteCollection, _
	name As String, _
	url As String, _
	defaults As Object, _
	namespaces As String() _
) As Route
'Usage
Dim routes As RouteCollection 
Dim name As String 
Dim url As String 
Dim defaults As Object 
Dim namespaces As String()
Dim returnValue As Route 

returnValue = routes.MapRoute(name, _
	url, defaults, namespaces)

Parameters

routes
Type: System.Web.Routing.RouteCollection

A collection of routes for the application.

name
Type: System.String

The name of the route to map.

url
Type: System.String

The URL pattern for the route.

defaults
Type: System.Object

An object that contains default route values.

namespaces
Type: System.String()

A set of namespaces for the application.

Return Value

Type: System.Web.Routing.Route
A reference to the mapped route.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type RouteCollection. When you use instance method syntax to call this method, omit the first parameter. For more information, see http://msdn.microsoft.com/en-us/library/bb384936(v=vs.108).aspx or http://msdn.microsoft.com/en-us/library/bb383977(v=vs.108).aspx.

ExceptionCondition
ArgumentNullException

The routes or url parameter is Nothing.

Show:
© 2014 Microsoft