title: Can periods be used in Asp.Net Web Api Routes?
body: <p>I'm working on moving an API project from raw http handlers where I'm using periods in the paths:</p>
  
  <pre><code>http://server/collection/id.format
  </code></pre>
  
  <p>I would like to follow the same URL schema in a Web Api (self-hosted) version, and tried this:</p>
  
  <pre><code>var c = new HttpSelfHostConfiguration(b);
  c.Routes.MapHttpRoute(
      name: "DefaultApiRoute",
      routeTemplate: "{controller}/{id}.{format}",
      defaults: new { id = RouteParameter.Optional, format = RouteParameter.Optional },
      constraints: null
  );
  </code></pre>
  
  <p>Unfortunately, that doesn't seem to resolve (consistent 404's on /foo, /foo/bar and /foo/bar.txt).  A similar pattern using a slash before 'format' works fine:</p>
  
  <pre><code>var c = new HttpSelfHostConfiguration(b);
  c.Routes.MapHttpRoute(
      name: "DefaultApiRoute",
      routeTemplate: "{controller}/{id}/{format}",
      defaults: new { id = RouteParameter.Optional, format = RouteParameter.Optional },
      constraints: null
  );
  </code></pre>
  
  <p>I haven't yet delved into the code for the Web Api, and before I do thought I'd ask here to see if this is a known, or perhaps even justified limitation in Web Api.</p>
  
  <p>UPDATE: I neglected to mention that "id" and "format" are strings, which turns out to be important for the solution to this question.  Adding a constraint to exclude periods from the "id" token solves the 404 problem.</p>