title: WCF REST Service returns HTTP 400 Bad Request
body: <p>I've been trying to create a simple WCF RESTful web service, but it seems to work only in SOAP mode. I'm hosting my service with the local IIS.</p>
  
  <p>It looks really standard:</p>
  
  <pre><code>[ServiceContract]
  public interface IMyService
  {
      [OperationContract]
      Guid Login(string username, string password);
  ...
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>public class MyService : IMyService
  {
      [WebGet(UriTemplate = "login?user={user}&amp;password={password}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
      public Guid Login(string username, string password)
      {
          return Guid.Empty;
      }
  </code></pre>
  
  <p>I also included the  behavior in the config file and was using it in:</p>
  
  <pre><code>&lt;endpoint address="" binding="webHttpBinding" contract="MyService" behaviorConfiguration="webHttp"/&gt;
  </code></pre>
  
  <p>according to all of the examples I know...</p>
  
  <p>Now the thing is when invoking the login from a stub client which uses ServiceReference, it looks just fine in Fiddler, but it is SOAPy.
  From some reason I cannot invoke my service in a RESTy way, even the /help seems to return a 400 Bad Request.
  (I'm invoking <a href="http://localhost:8080/MyService.svc/help" rel="nofollow">http://localhost:8080/MyService.svc/help</a> or /login etc.)</p>
  
  <p>What is preventing the REST to take action?
  Thanks in advance :)</p>
  
  <p><strong>Edit: I found an answer.</strong></p>
  
  <p>It turns out one must define <strong>Routings</strong>...</p>
  
  <p>After adding this to Global.asax :</p>
  
  <pre><code>    protected void Application_Start(object sender, EventArgs e)
      {
          RouteTable.Routes.Add(new ServiceRoute("MyService",
             new WebServiceHostFactory(), typeof(MyService)));
      }
  </code></pre>
  
  <p>It went through just fine.</p>
  
  <p>Plus I earned that the ".svc" is now not part of the URL.</p>