title: debugging asp.net WCF service hosted in IIS
body: <p>I have created a WCF service using following template:</p>
  
  <p><a href="http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd" rel="noreferrer">http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd</a></p>
  
  <p>This service has a method like this:</p>
  
  <pre><code>[ServiceContract]
      [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
      [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]    
      public class RecordingCompleted
      {
  
          [WebInvoke(UriTemplate = "", Method = "POST")]
          public string ProcessCall(string JsonData)
          {
  
          }
  
      }
  </code></pre>
  
  <p>I have hosted this service on IIS and url of the method is:</p>
  
  <p>http://[local] host/Notifications/RecordingCompleted/</p>
  
  <p>When I type this address in address bar, I get:</p>
  
  <pre><code>Method not allowed. Please see the service help page for constructing valid requests to the service.
  </code></pre>
  
  <p>I am trying consume this web service using following code:</p>
  
  <p>string serviceBaseUrl = "http://[local] host/Notifications/RecordingCompleted/";</p>
  
  <pre><code>        string resourceUrl = "";
          string method = "POST";
          //string jsonText = "}";
          UseHttpWebApproach(serviceBaseUrl, resourceUrl, method, jsonText);
  </code></pre>
  
  <p>and the methods are:</p>
  
  <pre><code>  private string UseHttpWebApproach(string serviceUrl, string resourceUrl, string method, string requestBody)
          {
              string responseMessage = null;
              var request = WebRequest.Create(string.Concat(serviceUrl, resourceUrl)) as HttpWebRequest;
              if (request != null)
              {
                  request.ContentType = "application/json";
                  request.Method = method;                 
              }
  
              //var objContent = HttpContentExtensions.CreateDataContract(requestBody);
              if (method == "POST" &amp;&amp; requestBody != null)
              {
                  byte[] requestBodyBytes = ToByteArrayUsingJsonContractSer(requestBody);
                  request.ContentLength = requestBodyBytes.Length;
                  using (Stream postStream = request.GetRequestStream())
                      postStream.Write(requestBodyBytes, 0, requestBodyBytes.Length);
  
              }
  
              if (request != null)
              {
                  var response = request.GetResponse() as HttpWebResponse;
                  if (response.StatusCode == HttpStatusCode.OK)
                  {
                      Stream responseStream = response.GetResponseStream();
                      if (responseStream != null)
                      {
                          var reader = new StreamReader(responseStream);
  
                          responseMessage = reader.ReadToEnd();
                      }
                  }
                  else
                  {
                      responseMessage = response.StatusDescription;
                  }
              }
              return responseMessage;
          }
  
  
  
   private static byte[] ToByteArrayUsingJsonContractSer(string requestBody)
      {
          byte[] bytes = null;
          var serializer1 = new DataContractJsonSerializer(typeof(string));
          var ms1 = new MemoryStream();
          serializer1.WriteObject(ms1, requestBody);
          ms1.Position = 0;
          var reader = new StreamReader(ms1);
          bytes = ms1.ToArray();
          return bytes;
      }
  </code></pre>
  
  <p>I am trying to debug the service method but I dont know how to do it. Please suggest me why I am getting error when I type 
  http://[local] host/Notifications/RecordingCompleted/ in address bar. And how to debug the service which is hosted on local host ?</p>
  
  <p>Regards,
  Asif Hameed</p>