title: How to access data sent from HttpWebRequest Stream via window.location.href in Java Script
body: <p>I am relatively new to web programming.
  I have a windows form trying to communicate with a web service through ajax and java scripts.
  My form has below code,</p>
  
  <pre><code>        string sURL = &lt;&lt;URL&gt;&gt;;
          HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(sURL);
  
          //Modify request properties
          request.Method = "POST";
          request.ContentType = "application/x-www-form-urlencoded";
          request.AllowAutoRedirect = false;
          request.AllowWriteStreamBuffering = false;
  
          string sRequestData = JsonConvert.SerializeObject(new GetSessionInfo() { UserName = "xxxxxx", Database = "xxxxxx", Module = "xxxxxx" }.ToString());
  
          StreamWriter sWriter = new StreamWriter(request.GetRequestStream());
          sWriter.Write(sRequestData);
          sWriter.Close();
  
          try
          {
              //Extract the response
              HttpWebResponse response = request.GetResponse() as HttpWebResponse;
              if (response == null)
                  return false;
  
              StreamReader responcestream = new StreamReader(response.GetResponseStream());
              string ResponseData = responcestream.ReadToEnd();
              responcestream.Close();
              return true;
          }
          catch
          {
              throw;
          }
  </code></pre>
  
  <p>My index.html file looks like below</p>
  
  <pre><code>        function Session()
          {   
              $.ajax({
                  type: "POST",
                  url: "/ProcessRequestFromEasyOrder",
                  data : JSON.stringify({ user:"****", Database:"****", module:"****"}),
                  contentType: "application/json; charset=utf-8",
                  dataType: "application/json",
                  async: true,
                  cache: false,
                  cors: true,
                  success:function(data){
                      alert(data);
                  }
              });
          }
  </code></pre>
  
  <p>At the moment I am able to call web service methods by hard coding parameters through browser. However when I try to do it via my windows form it always return me (405)Method Not Allowed.
  Can someone please help me answer following questions,</p>
  
  <ul>
  <li>Can this be achieve? if so can you provide an example which achieve
  this?</li>
  <li>Is it due to an issue with web service settings? if so how do
  I get it fixed?   </li>
  <li>Any alternative ways to do this? an example would
  be great</li>
  </ul>
  
  <p>I am on .NET 4.5
  Thank you very much for your help!</p>