New to Telerik Reporting? Download free 30-day trial

Multiple actions were found that match the request

Environment

Product Progress® Telerik® Reporting
Project Type ASP.NET Framework

Description

After implementing the Reporting REST Service in an ASP.NET Framework application - Telerik Reporting REST Service ASP.NET Web API Implementation, when the application starts, the error page is displayed with details about a problem with the ReportsController.

Error Message

<Error>
    <Message>An error has occurred.</Message>
    <ExceptionMessage>Multiple actions were found that match the request: Formats on type Controllers.ReportsController GetClientsSessionTimeoutSeconds on type Controllers.ReportsController Version on type     Controllers.ReportsController</ExceptionMessage>
    <ExceptionType>System.InvalidOperationException</ExceptionType>
    <StackTrace> at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContext controllerContext) at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()</StackTrace>
</Error>

Cause

The issue is likely caused by a greedy route in the route configuration, which interferes with the proper registration and functioning of the Reporting REST service routes. This can occur when the reporting routes are not prioritized in the route registration order.

Solution

Solution 1

To resolve this issue, ensure that the reporting routes are registered before the default ones. This action gives them priority and prevents them from being overridden by other more general routes. Use the following steps:

  1. Register the reporting routes before any default or other custom routes in your Web API configuration:

    Telerik.Reporting.Services.WebApi.ReportsControllerConfiguration.RegisterRoutes(config);
    
    config.Routes.MapHttpRoute(
        name: "DefaultApi",
        routeTemplate: "api/{controller}/{action}/{id}",
        defaults: new { id = RouteParameter.Optional }
    );
    
  2. Verify that the routeTemplate includes the {action} part. Omitting this can cause issues due to multiple actions matching the same route template.

Solution 2

Change the first path segment included in the route template using the ReportsControllerConfiguration.RegisterRoutes(HttpConfiguration, String) method overload.

For example, "api" is the default literal path segment in the "api/{controller}" route template. Use this overload and pass a unique path segment (e.g. "reportingapi") to avoid collisions with other Web API services - Telerik.Reporting.Services.WebApi.ReportsControllerConfiguration.RegisterRoutes(config, "reportingapi");

See Also

In this article