RouteCollectionBuilder<TBuilder, TRouteType>.MapRoute(Action<ControlRouteBuilder<TRouteType>>) Method

Defines the request routing logic by specifying the request type along with the names of a Controller and an Action, which should handle it.

Namespace: DevExpress.AspNetCore.Bootstrap

Assembly: DevExpress.AspNetCore.Bootstrap.v18.1.dll

Syntax

public TBuilder MapRoute(Action<ControlRouteBuilder<TRouteType>> config)

Parameters

Type Name Description
System.Action<ControlRouteBuilder<TRouteType>> config

An action performing the required configurations through a ControlRouteBuilder object.

Returns

Type Description
TBuilder

A reference to this instance after the operation is completed.

Use the MapRoute method to associate requests of the specified type with the specific handling action on the controller side. To achieve this, you need to provide the following settings:

  • RouteType - Specifies the type of the requests to handle. Skip this setting to specify the default route.
  • Controller - Specifies the name of a controller, whose action should handle the request.
  • Action - Specifies the name of a controller action to handle the request.
  • RouteValues - Allows you to specify the route in a cusotom form (e.g., to pass aditional parameters to the handling action).

The code sample below shows how to specify routes to handle various requests from the Grid View control:

@(Html.DevExpress()
    .BootstrapGridView<EditableEmployee>()
    .Name("gridView")
    .Routes(routes => routes
        .MapRoute(r => r
            .Controller("Home"))
            .Action("GridViewPartialView")
        .MapRoute(r => r
            .RouteType(GridViewRouteType.AddRow)
            .Action("InsertRow")
            .Controller("Home"))
        .MapRoute(r => r
            .RouteType(GridViewRouteType.UpdateRow)
            .Action("UpdateRow")
            .Controller("Home"))
        .MapRoute(r => r
            .RouteType(GridViewRouteType.DeleteRow)
            .Action("DeleteRow")
            .Controller("Home")))
    .Bind(Model))
    ...