Issue with OData v3 $batch Endpoint in Web API 2.2 running on IIS 7.5 RRS feed

  • Question

  • I have a Visual Studio 2013 Web API OData project that I want to get batch processing working with it. I can run it fine on my local desktop from Visual Studio and get a 202 response just fine. When I deploy it to a Windows Server 2008 sp 1 with .NET Framework 4.5 and IIS 7.5, it will run all other commands except for the $batch command.

    Here is the request below:

    POST http://apps/BookingsOData/v3/$batch HTTP/1.1
    User-Agent: Fiddler
    Content-ID: 1
    Host: apps
    Accept: application/atom+xml,application/xml
    Content-Type: multipart/mixed; boundary="batch_357647d1-a6b5-4e6a-aa73-edfc88d8866e"
    Content-Length: 2102
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
    <title />
    <name />
    <id />
    <content type="application/xml">
    <d:BookDate m:null="true" />
    <d:BookTime m:null="true" />

    On my personal desktop where I developed the program, I get a normal 202 response and see that the record has been added to the database.

    When I deploy the application to the server running IIS 7.5, I get the following response with the same request:

    HTTP/1.1 404 Not Found
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Type: application/xml; charset=utf-8
    Expires: -1
    Server: Microsoft-IIS/7.5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Fri, 16 Sep 2016 19:01:38 GMT
    Content-Length: 262
    <Error><Message>No HTTP resource was found that matches the request URI 'http://apps/BookingsOData/v3/$batch'.</Message><MessageDetail>No route providing a controller name was found to match request URI 'http://apps/BookingsOData/v3/$batch'</MessageDetail></Error>

    Here are the files that I have with the project that may be associated with the OData Batch implementation: global.asax

    using BookingsOData.App_Start;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Http;
    using System.Web.Routing;
    namespace BoookingsOData
        public class WebApiApplication : System.Web.HttpApplication
            protected void Application_Start()
                GlobalConfiguration.Configure(config =>


    using BookingsOData.Models;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Http;
    using System.Web.Http.OData;
    using System.Web.Http.OData.Extensions;
    using System.Web.Http.OData.Builder;
    using System.Web.Http.OData.Batch;
    using Microsoft.Data.Edm;
    namespace BookingsOData.App_Start
        public class ODataConfig
            public static void Register(HttpConfiguration config)
                // Web API routes
                // Web API configuration and services
                var builder = new ODataConventionModelBuilder();
                //builder.Namespace = typeof(BookingRequest).Namespace;
                builder.Namespace = "BookingsOData";
                builder.ContainerName = "GiContext";
                // Get EDM model
                var model = builder.GetEdmModel();
                // Setup batch handler
                var batchHandler = new EntityFrameworkBatchHandler(GlobalConfiguration.DefaultServer);
                // Setup OData route
                config.Routes.MapODataServiceRoute("ODataRoute", "v3", model, batchHandler);


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web.Http;
    using System.Net.Http.Formatting;
    using System.Web.Http.OData.Formatter;
    namespace BookingsOData
        public static class WebApiConfig
            public static void Register(HttpConfiguration config)
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }


    <?xml version="1.0"?>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
        <add name="Entities" connectionString="metadata=res://*/Models.BookingsModel.csdl|res://*/Models.BookingsModel.ssdl|res://*/Models.BookingsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=servername;initial catalog=myDB;user id=user;password=pass;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
        <compilation debug="true" targetFramework="4.5"/>
        <pages controlRenderingCompatibilityVersion="4.0"/>
        <customErrors mode="Off" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
          <remove name="OPTIONSVerbHandler"/>
          <remove name="TRACEVerbHandler"/>
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*" verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0"/>
        <httpErrors errorMode="Detailed" />
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="" newVersion=""/>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="" newVersion=""/>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="" newVersion=""/>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
            <bindingRedirect oldVersion="" newVersion=""/>
            <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
            <bindingRedirect oldVersion="" newVersion=""/>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            <binding name="BookingsOData.OData.customBinding0">
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

    What could be causing the the deployed version not to work with $batch command when all other endpoints work fine?

    • Moved by Kevin Linq Monday, September 19, 2016 3:23 AM
    Friday, September 16, 2016 8:55 PM

All replies

  • Hi MBollich,

    Thank you for posting here.

    Since your issue is related to ASP.net web api , I will move your thread to off-topic . 

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Here is the link of  ASP.net web api forum:http://forums.asp.net/1246.aspx/1?Web+API

    If you have anything else regarding C# programming , please feel free to let me know . 

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Monday, September 19, 2016 3:22 AM