title: Method not allowed error when using WCF POST method
body: <p>Iam using POST method in wcf. But it returns "Method not allowed" error when trying to access using the client application.</p>
  
  <p>My Method:</p>
  
  <pre><code>[OperationContract]
  
  [WebInvoke(
          Method = "POST",
          BodyStyle = WebMessageBodyStyle.Bare,
          UriTemplate = "/Upload/{fileName}")]
  
         void Upload(string fileName,Stream data)
        {
  
          FileStream fileToupload = new FileStream("D:\\FileUpload\\" + fileName, FileMode.Create);
  
          byte[] bytearray = new byte[10000];
          int bytesRead, totalBytesRead = 0;
          do
          {
              bytesRead = data.Read(bytearray, 0, bytearray.Length);
              totalBytesRead += bytesRead;
          } while (bytesRead &gt; 0);
  
          fileToupload.Write(bytearray, 0, bytearray.Length);
          fileToupload.Close();
          fileToupload.Dispose();
        }
  </code></pre>
  
  <p>My Client code:</p>
  
  <pre><code>        byte[] bytearray = null;
          string name = "";
          //throw new NotImplementedException();
          if (FileUpload1.HasFile)
          {
              name = FileUpload1.FileName;
              Stream stream = FileUpload1.FileContent;
              stream.Seek(0, SeekOrigin.Begin);
              bytearray = new byte[stream.Length];
              int count = 0;
              while (count &lt; stream.Length)
              {
                  bytearray[count++] = Convert.ToByte(stream.ReadByte());
              }
          }
  
          string baseAddress = "http://localhost:49798/WcfPostMet/Service.svc/Upload/";
          HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(baseAddress+name);
          request.Method = "POST";
          request.ContentType = "text/plain";
          Stream serverStream = request.GetRequestStream();
          serverStream.Write(bytearray, 0, bytearray.Length);
          serverStream.Close();
          //using (
          HttpWebResponse response = request.GetResponse() as HttpWebResponse;
          {
              int statusCode = (int)response.StatusCode;
              StreamReader reader = new StreamReader(response.GetResponseStream());
          }
  </code></pre>
  
  <p>I have not modified the web.config file.</p>
  
  <p>Any Suggestion.........</p>