title: Web Api 2.2 OData V4 Function Routing
body: <p>I have a Web Api 2.2 project working with OData v4.  The normal EntitySet configuration is working as desired with all http verbs.  Where I am having a problem is trying to expose a custom function.  I started off trying to do something different than the standard examples, but I have backed all the way up to just trying to getting a basic example function working.</p>
  
  <p>Here is my startup config (straight from the MS examples):</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web.Http;
  using System.Web.OData.Builder;
  using System.Web.OData.Extensions;
  
  namespace Test.Service
  {
      public static class WebApiConfig
      {
          public static void Register(HttpConfiguration config)
          {
  
              // other entitysets that don't have functions
  
              builder.EntitySet&lt;Product&gt;("Products");
              builder.Namespace = "ProductService";
              builder.EntityType&lt;Product&gt;().Collection
                  .Function("MostExpensive")
                  .Returns&lt;double&gt;();
  
              config.MapODataServiceRoute(
                  "odataroute"
                  , "odata"
                  , builder.GetEdmModel()                        
                  );
          }
      }
  }
  </code></pre>
  
  <p>And here is my controller:</p>
  
  <pre><code>using System.Data.Entity;
  using System.Data.Entity.Infrastructure;
  using System.Linq;
  using System.Net;
  using System.Threading.Tasks;
  using System.Web.Http;
  using System.Web.OData;
  
  namespace Test.Service.Controllers
  {
      public class ProductsController : ODataController
      {
          private EntityContext db = new EntityContext();
  
          [EnableQuery]
          public IQueryable&lt;Product&gt; GetProducts()
          {
              return db.Products;
          }
  
          [HttpGet]
          public IHttpActionResult MostExpensive()
          {
              double test = 10.3;
              return Ok(test);
          }
      }
  }
  </code></pre>
  
  <p>The regular GET, works fine:</p>
  
  <pre><code>http://something/odata/Products
  </code></pre>
  
  <p>However, the following always gives me a 404:</p>
  
  <pre><code>http://something/odata/Products/ProductService.MostExpensive()
  </code></pre>
  
  <p>I have tried any number of different things with the namespace, etc...  So, it doesn't work like all of the examples, but I'm at a loss at how to dig in deeper to figure out what is going wrong.  The metadata exposed by <code>http://something/odata</code> doesn't provide any clues.  Is there any other way to discover where (and how) this function should be exposed?</p>
  
  <p>EDIT: Here is the link to the Microsoft Example I am following:
  <a href="http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/odata-actions-and-functions">http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/odata-actions-and-functions</a></p>