title: How to allow method in C# web service to retrieve data from website?
body: <p>This is my restful web service code.And I tried to get some data from web site.But in there is an error occurred.It says "NetworkError: 405 Method Not Allowed " What I can do to prevent this.</p>
  
  <pre><code>    namespace WebService1
      {
         [System.Web.Script.Services.ScriptService]
         [WebService(Namespace = "http://microsoft.com/webservices/")]
         [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
         [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
         public class Service1 : System.Web.Services.WebService 
         {
              public Service1()
              {
              }
  
              [WebMethod]
              [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
              public string sayHelloJson(string name)
              {
                  string strgreeting = string.Format("Hello {0}", name);
                  JavaScriptSerializer js = new JavaScriptSerializer();
                  return js.Serialize(strgreeting);
              }
          }
      }
  </code></pre>
  
  <p>This is my html code.I run it using wamp server..</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
      &lt;meta content="text/html;charset=utf-8" http-equiv="Content-Type"&gt;
      &lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
      function Greeting(){
  
           var Name=$('#txtname').val();
  
              $.ajax({
              type: "POST",
              url: 'http://localhost:54884/Service1.asmx?op=ssayHelloJson',
              //data: ({ name : 'ggg' }),
              dataType: "html",
               contentType: "application/x-www-form-urlencoded",
              success: function(data) {
                  // Run the code here that needs
                  //    to access the data returned
                  alert( data);
              },
              error: function() {
                  alert('Error occured');
              }
          });
      }
  
      &lt;/script&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form id="form1" &gt;
      &lt;div&gt;
          &lt;p&gt;json format call&lt;/p&gt;
          Enter name:&lt;input type="text" id="txtname" /&gt;
          &lt;input type="button" id="btngo" value="GO" onclick="Greeting()" /&gt;
  
  
      &lt;/div&gt;
      &lt;p id="result"&gt;&lt;/p&gt;
  
  
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>