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].
Here's the ASPX code:
<asp:DdlNoEventValidation ID="ddlWasteTypeList" runat="server" />
<asp:DdlNoEventValidation ID="ddlBinTypeList" runat="server" />
<asp:CustomValidator
ID="CustomValidator1" runat="server"
ControlToValidate="ddlBinTypeList"
OnServerValidate="CustomValidatorBinType_ServerValidate"
ValidateEmptyText="True"
>
</asp:CustomValidator>
<asp:CascadingDropDown ID="ccd1" runat="server"
ServicePath="WasteDropDown.asmx"
ServiceMethod="GetWaste"
TargetControlID="ddlWasteTypeList"
Category="Waste"
PromptText="select waste" LoadingText="[Loading waste...]"
/>
<asp:CascadingDropDown ID="ccd2" runat="server"
ServicePath="WasteDropDown.asmx"
ServiceMethod="GetBinType"
TargetControlID="ddlBinTypeList"
ParentControlID="ddlWasteTypeList"
Category="BinType"
PromptText="select bin" LoadingText="[Loading bins...]"
/>
Here's the asmx code behind:
[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<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
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<CascadingDropDownNameValue> l = new List<CascadingDropDownNameValue>();
while (dr.Read())
{
l.Add(new CascadingDropDownNameValue(
dr["binWT"].ToString(),
dr["wtID"].ToString()));
}
conn.Close();
return l.ToArray();
}
}
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.
I did have a look at this Stackoverflow question, 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.
I've double checked the SQL queries and they both return data.
Any suggestions? I've run out of them!
EDIT:
I've set up Failed Request Tracing and get this really helpful result:
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
The same error was generated for /wastedropdown.asmx/getwaste and wastedropdown.asmx/getbintype
Hopefully this will mean something to someone!
EDIT2:
The code definitely works fine on a different website on the same server. I've got Fiddler out at get the following error:
{"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"}
HELP!