title: AJAX Cascading Dropdown with Method Error 500
body: <p>I've have a c# cascadingdropdown which works perfectly in debug locally and in debug mode on the live server, but I get [Method Error 500] in both drop downs when I view the page live through a browser. If I click the first drop down [Method Error 500] that then populates the second dropdown with [Method Error 500].</p>
  
  <p>Here's the ASPX code:</p>
  
  <pre><code>&lt;asp:DdlNoEventValidation ID="ddlWasteTypeList" runat="server" /&gt;
  &lt;asp:DdlNoEventValidation ID="ddlBinTypeList" runat="server" /&gt;
  
  &lt;asp:CustomValidator 
      ID="CustomValidator1" runat="server" 
      ControlToValidate="ddlBinTypeList"  
      OnServerValidate="CustomValidatorBinType_ServerValidate"
      ValidateEmptyText="True"
      &gt;
  &lt;/asp:CustomValidator&gt;
  
  &lt;asp:CascadingDropDown ID="ccd1" runat="server"
      ServicePath="WasteDropDown.asmx"
      ServiceMethod="GetWaste"
      TargetControlID="ddlWasteTypeList"
      Category="Waste"
      PromptText="select waste" LoadingText="[Loading waste...]"
  /&gt;
  &lt;asp:CascadingDropDown ID="ccd2" runat="server"
      ServicePath="WasteDropDown.asmx"
      ServiceMethod="GetBinType"
      TargetControlID="ddlBinTypeList"
      ParentControlID="ddlWasteTypeList"
      Category="BinType"
      PromptText="select bin" LoadingText="[Loading bins...]"
  /&gt;
  </code></pre>
  
  <p>Here's the asmx code behind:</p>
  
  <pre><code>[ScriptService]
  public class WasteDropDown : System.Web.Services.WebService 
  {
      [WebMethod]
      public CascadingDropDownNameValue[] GetBinType(string knownCategoryValues, string category)
      {
          int wtID;
          StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
          if (!kv.ContainsKey("Waste") || !Int32.TryParse(kv["Waste"], out wtID))
          {
              throw new ArgumentException("Couldn't find waste type.");
          };
  
          SqlConnection conn = new SqlConnection(myConn.conn);
          conn.Open();
          SqlCommand comm;
          comm = new SqlCommand("dbo.sl_TLU", conn);
          comm.CommandType = CommandType.StoredProcedure;
          comm.Parameters.Add(new SqlParameter("@binWTID", SqlDbType.Int));
          comm.Parameters["@binWTID"].Value = wtID;
  
          SqlDataReader dr = comm.ExecuteReader();
          List&lt;CascadingDropDownNameValue&gt; l = new List&lt;CascadingDropDownNameValue&gt;();
  
          while (dr.Read())
          {
              l.Add(new CascadingDropDownNameValue(
              dr["bT"].ToString(),
              dr["bPLUID"].ToString()));
          }
          conn.Close();
          return l.ToArray();
      }
  
      [WebMethod]
      public CascadingDropDownNameValue[] GetWaste(string knownCategoryValues, string category)
      {
          SqlConnection conn = new SqlConnection(myConn.conn);
          conn.Open();
  
          SqlCommand comm;
          comm = new SqlCommand("dbo.sl_binQWT", conn);
          comm.CommandType = CommandType.StoredProcedure;
  
          SqlDataReader dr = comm.ExecuteReader();
          List&lt;CascadingDropDownNameValue&gt; l = new List&lt;CascadingDropDownNameValue&gt;();
  
          while (dr.Read())
          {
              l.Add(new CascadingDropDownNameValue(
              dr["binWT"].ToString(),
              dr["wtID"].ToString()));
          }
          conn.Close();
          return l.ToArray();
      }
  }
  </code></pre>
  
  <p>There's no ASP.Net errors in the logs. However, I have a similar ccd running on the same server on a different website and that works perfectly - very frustrating. </p>
  
  <p>I did have a look at <a href="https://stackoverflow.com/questions/8356731/hosting-the-application-in-iis-cascading-dropdown-with-ajax-is-display-the-metho">this Stackoverflow question</a>, but to be honest I didn't quite get what the solution was - although I don't seem to have any duplicate dlls in the bin folder. I really think the issue is around here somewhere though. </p>
  
  <p>I've double checked the SQL queries and they both return data.</p>
  
  <p>Any suggestions? I've run out of them!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've set up Failed Request Tracing and get this really helpful result:</p>
  
  <blockquote>
    <p>MODULE_SET_RESPONSE_ERROR_STATUS 
    Warning
    ModuleName="ManagedPipelineHandler",
    Notification="MAP_REQUEST_HANDLER", HttpStatus="500",
    HttpReason="Internal Server Error", HttpSubStatus="0", ErrorCode="The
    operation completed successfully.  (0x0)", ConfigExceptionInfo=""Warning</p>
  </blockquote>
  
  <p>The same error was generated for /wastedropdown.asmx/getwaste and wastedropdown.asmx/getbintype </p>
  
  <p>Hopefully this will mean something to someone!</p>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>The code definitely works fine on a different website on the same server. I've got Fiddler out at get the following error:</p>
  
  <blockquote>
    <p>{"Message":"An attempt was made to call the method
    \u0027GetWaste\u0027 using a GET request, which is not
    allowed.","StackTrace":"   at
    System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData
    methodData, HttpContext context)\r\n   at
    System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
    context, WebServiceMethodData
    methodData)","ExceptionType":"System.InvalidOperationException"}</p>
  </blockquote>
  
  <p>HELP!</p>