title: Configuring a simple WCF Service Endpoint in a ASP.NET MVC 2.0
body: <p>I'm building a simple ASP.NET MVC 2.0 web application. I'd like to serve up a AtomPub endpoint so that I can publish/update content from Windows Live Writer. I originally went down the path of implementing the AtomPub protocol as an Controller with a set of custom ActionResults. That worked until I tried to get authentication working, when I realized that getting Basic or Digest auth (necessary for WLW) to work within my Forms-Auth based MVC app was going to be problematic.</p>
  
  <p>So, now I've decided to move the AtomPub logic to a WCF service within the MVC app. I created a new WCF service called AtomPub.svc. I added the following to my web.config file:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name=""&gt;
          &lt;serviceMetadata httpGetEnabled="true" /&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>And, my AtomPub.svc.cs code behind looks like this:</p>
  
  <pre><code>namespace Web
  {
      using System.ServiceModel;
      using System.ServiceModel.Web;
  
      [ServiceContract]
      public partial class AtomPub
      {
          [WebGet(UriTemplate = "?test={test}")]
          [OperationContract]
          public string DoWork(string test)
          {
              return test;
          }
      }
  }
  </code></pre>
  
  <p>I also added a route exclusion to exclude this endpoint from MVC's route handling. </p>
  
  <p>Now, I'm a total noob to WCF, so I'm sure I'm doing a number of things wrong. As I'm writing this, the root of the endpoint seems to be working as I get an AtomPub Service page. The URL templating, however, is not working and I don't know what to do to get it working. I'd love to hear your suggestions.</p>
  
  <p>By the way, I'm trying to keep this overall implementation as simple as possible. So, I'm not looking to introduce a dependency on the Entity Framework so I can use WCF Data Services. I'd also prefer not to move the WCF endpoint into a separate project, though I'm open to that if I can easily deploy it to a W2k3/IIS6 environment.</p>