title: CORS on Self Hosted WCF Service
body: <p>I'm trying to implement CORS suppor into my WCF service.</p>
  
  <p>I got some codes from </p>
  
  <p><a href="https://enable-cors.org/server_wcf.html" rel="nofollow noreferrer">https://enable-cors.org/server_wcf.html</a></p>
  
  <pre><code>public class CustomHeaderMessageInspector : IDispatchMessageInspector
          {
              Dictionary&lt;string, string&gt; requiredHeaders;
              public CustomHeaderMessageInspector (Dictionary&lt;string, string&gt; headers)
              {
                  requiredHeaders = headers ?? new Dictionary&lt;string, string&gt;();
              }
  
              public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
              {
                  return null;
              }
  
              public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
              {
                  var httpHeader = reply.Properties["httpResponse"] as HttpResponseMessageProperty;
                  foreach (var item in requiredHeaders)
                  {
                      httpHeader.Headers.Add(item.Key, item.Value);
                  }           
              }
          }
  </code></pre>
  
  <p>But I'm getting error message on this line</p>
  
  <pre><code>public class CustomHeaderMessageInspector : IDispatchMessageInspector
  </code></pre>
  
  <p>ERROR: <strong>Classes can inherit only from other classes</strong></p>
  
  <p>How can i inherit <strong>IDispatchMessageInspector</strong></p>
  
  <p>Thanks</p>