title: WCF REST => Method = Delete => (403) Forbidden
body: <p>I'm performing GET, POST and DELETE operations from my WCF REST service. While GET &amp; POST works well, DELETE is not working.</p>
  
  <p>From my client application, when i try to call delete it says below error.
  <strong>Error Message:</strong> The remote server returned an error: (403) Forbidden.</p>
  
  <p><strong>My code:</strong></p>
  
  <p><strong>Data contract:</strong></p>
  
  <pre><code>[WebInvoke(Method = "DELETE", UriTemplate = "users/", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  [OperationContract]
  string DeleteUser(UserInfo userinfo);
  </code></pre>
  
  <p><strong>Implementation:</strong></p>
  
  <pre><code>public string DeleteUser(UserInfo userinfo)
  {
      string sResult = "";
  
      try
      {
          UserDataAccess dataAccess = new UserDataAccess();
  
          sResult = dataAccess.DeleteUser(userinfo.GEId);
      }
      catch (Exception ex)
      {
          oLog.LogError(ex, true);
          sResult = ex.Message;
      }
  
      return sResult;
  }
  </code></pre>
  
  <p><strong>Consuming Code:</strong></p>
  
  <pre><code>protected void btDeleteAsJson_Click(object sender, EventArgs e)
  {
      UserInfo user = new UserInfo();
  
      user.GEId = Convert.ToInt32(txtGEID.Text);
  
      JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
      string output = jsSerializer.Serialize(user);
  
      SendMessageDeleteJson(apiUrl, output);
  }
  
  public void SendMessageDeleteJson(string endPoint, string output)
  {
      string data = output;
  
      byte[] bytes = Encoding.UTF8.GetBytes(data);
  
      HttpWebRequest request = CreateWebRequest1(endPoint, bytes.Length, "application/json");
  
      using (var requestStream = request.GetRequestStream())
      {
          requestStream.Write(bytes, 0, bytes.Length);
      }
  
      using (var response = (HttpWebResponse)request.GetResponse())
      {
          if (response.StatusCode != HttpStatusCode.OK)
          {
              string message = String.Format("DELETE failed. Received HTTP {0}", response.StatusCode);
              throw new ApplicationException(message);
          }
  
          Stream responseStream = response.GetResponseStream();
          StreamReader reader = new StreamReader(responseStream);
          string sResponseStream = reader.ReadToEnd();
  
          lblDeleteSuccess.Text = "Success! User has beed deleted";
      }
  }
  
  private HttpWebRequest CreateWebRequest1(string endPoint, Int32 contentLength, string ContentType)
  {
      var request = (HttpWebRequest)WebRequest.Create(endPoint);
  
      request.Method = "DELETE";
      request.ContentLength = contentLength;
      //request.ContentType = "application/x-www-form-urlencoded";
      request.ContentType = ContentType;
  
      return request;
  }
  </code></pre>
  
  <p>Could you please point me where I'm wrong?</p>