Skip to content

No MapODataServiceRoute() extension method with both ODataBatchHandler and HttpMessageHandler #1885

@Andos25

Description

@Andos25

Currently I'm trying to add per-route delegating handler. but seems there is no proper method in src/Microsoft.AspNet.OData/Extensions/HttpConfigurationExtensions.cs which can support both ODataBatchHandler and HttpMessageHandler as parameters. It is a common case if we want use ODataBatchHandler + HttpMessageHandler

Assemblies affected

*Which assemblies and versions are known to be affected e.g. OData WebApi lib 5.9.0

Additional detail

In order to solve the issue, I have to create my own extension method as below

        public static void MapODataServiceRouteWithHandler(
            this HttpConfiguration httpConfiguration,
            string routeName,
            string routePrefix,
            IEdmModel model,
            List<IODataRoutingConvention> routingConventions,
            IODataPathHandler pathHandler,
            HttpMessageHandler defaultHandler,
            ODataBatchHandler batchHandler)
        {
            HttpRouteCollection routes = httpConfiguration.Routes;
            if (batchHandler != null)
            {
                batchHandler.ODataRouteName = routeName;
                string routeTemplate = string.IsNullOrEmpty(routePrefix) ? ODataRouteConstants.Batch : routePrefix + (object)'/' + ODataRouteConstants.Batch;
                routes.MapHttpBatchRoute(routeName + "Batch", routeTemplate, batchHandler);
            }
            routingConventions.AddRange(ODataRoutingConventions.CreateDefaultWithAttributeRouting(httpConfiguration, model));
            httpConfiguration.MapODataServiceRoute(
                routeName: routeName,
                routePrefix: routePrefix,
                model: model,
                pathHandler: pathHandler,
                routingConventions: routingConventions,
                defaultHandler: defaultHandler);
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions