title: WebApi attribute routing defined on interface
body: <p>I'm trying to convert a WCF/REST service project to MVC/WebAPI. The service layer is implemented multiple times as a wrapper for different end systems, and all implementations observe a common contract defined in an interface (<code>IContract</code>). With WCF, we defined <code>[WebInvoke]</code> and <code>[OperationContract]</code> attributes on each of the methods which were exposed as web service methods. In WebAPI, this can be simplified with attribute routing defined on the controller. However, I would like to keep the route attributes defined on the interface, so all the implementations behave similarly.</p>
  
  <p>Here's a sample of the old interface:</p>
  
  <pre><code>[ServiceContract]
  public interface IContract
  {
      [WebInvoke(UriTemplate = "Version", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
      [OperationContract]
      string GetVersion();
  }
  </code></pre>
  
  <p>Here's what I was hoping to get working:</p>
  
  <pre><code>public interface IContract
  {
      [Route("Version")]
      [HttpGet]
      string GetVersion();
  }
  </code></pre>
  
  <p>I would also consider creating an abstract base class, but this other <a href="https://stackoverflow.com/questions/19989023/net-webapi-attribute-routing-and-inheritance">StackOverflow question</a> makes me think there isn't a suitable replacement for <code>[WebInvoke(UriTemplate)]</code> using WebAPI attribute routing. Is that the case, or can someone point me to a similar, supported technique?</p>
  
  <p>Thanks</p>