title: The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'apiVersion'
body: <p>I have a basic WebApi implementation setup with the default Values controller.</p>
  <p>After <a href="https://www.hanselman.com/blog/ASPNETCoreRESTfulWebAPIVersioningMadeEasy.aspx" rel="nofollow noreferrer">reading a blog about RESTful WebApi Versioning</a> I decided to integrate the package into a new WebApi project.</p>
  <p>I've added the NuGet package Microsoft.AspNet.WebApi.Versioning to assist with the versioning of my API.  Here is the URL to the packages configuration instructions that I am following:</p>
  <p><a href="https://github.com/Microsoft/aspnet-api-versioning/wiki/Configuring-Your-Application" rel="nofollow noreferrer">https://github.com/Microsoft/aspnet-api-versioning/wiki/Configuring-Your-Application</a></p>
  <p>My values controller is very straightforward.  I've added the decoration to my Get method.  Here is the code:</p>
  <pre><code>[Authorize]
  [ApiVersion(&quot;1.0&quot;)]
  [Route(&quot;api/v{version:apiVersion}/values&quot;)]
  public class ValuesController : ApiController
  {
      // GET api/values
      public IEnumerable&lt;string&gt; Get()
      {
          return new string[] { &quot;value1&quot;, &quot;value2&quot; };
      }
      
      public string Get(int id)
      {
          return &quot;value&quot;;
      }
  
      // POST api/values
      public void Post([FromBody]string value)
      {
      }
  
      // PUT api/values/5
      public void Put(int id, [FromBody]string value)
      {
      }
  
      // DELETE api/values/5
      public void Delete(int id)
      {
      }
  }
  </code></pre>
  <p>Unfortunately, as soon as I add the following line of code to the controller the whole thing blows up:</p>
  <pre><code>[Route(&quot;api/v{version:apiVersion}/values&quot;)]
  </code></pre>
  <p>Here is a peek at the error message that is being returned:</p>
  <pre><code>The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'apiVersion'. 
  
  Line 82:             GlobalConfiguration.Configure(WebApiConfig.Register);
  </code></pre>
  <p>Here is the code I have inside of my Startup.cs</p>
  <pre><code>public void Configuration(IAppBuilder app)
  {
      // HTTP Configuration
      HttpConfiguration config = new HttpConfiguration();
      //config.MapHttpAttributeRoutes();
  
      // Configure API Versioning
      config.AddApiVersioning();
      var constraintResolver = new DefaultInlineConstraintResolver()
      {
          ConstraintMap =
          {
              [&quot;apiVersion&quot;] = typeof( ApiVersionRouteConstraint ) // or mvc routing?
          }
      };
      config.MapHttpAttributeRoutes(constraintResolver);   
  
      // Configure the API to accept token authentication
      ConfigureOAuthTokenConsumption(app);
  
      // CORS
      app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
  
      // Configure the Authorization server
      ConfigureOAuth(app);
  
      // Use WebAPI
      app.UseWebApi(config);
  
      // Moved from global.asax
      AreaRegistration.RegisterAllAreas();
      GlobalConfiguration.Configure(WebApiConfig.Register);
      FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
      RouteConfig.RegisterRoutes(RouteTable.Routes);
      BundleConfig.RegisterBundles(BundleTable.Bundles);
  }
  </code></pre>
  <p>I thought that calling AddApiVersioning and supplying the constraintResolver as outlined in the documentation would fix the issue, but it did not.  Now I am struggling with what to do next.</p>
  <pre><code>config.AddApiVersioning();
  var constraintResolver = new DefaultInlineConstraintResolver()
  {
      ConstraintMap =
      {
          [&quot;apiVersion&quot;] = typeof( ApiVersionRouteConstraint ) // or mvc routing?
      }
  };
  config.MapHttpAttributeRoutes(constraintResolver);
  </code></pre>
  <p>Any suggestions?</p>