我已经有ac#cascadingdropdown,它可以在本地调试和在调试模式下在活动服务器上完美地工作,但当我查看实时页面时,我在两个下拉菜单中都会看到[方法错误500]通过浏览器。如果我点击第一个下拉[方法错误500],然后用[方法错误500]填充第二个下拉列表。AJAX级联下拉方法错误500
这里的ASPX代码:
<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...]"
/>
这里是背后的ASMX代码:
[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();
}
}
有没有在日志中没有ASP.Net错误。但是,我在另一个网站上的同一台服务器上运行了类似的ccd,并且运行完美 - 非常令人沮丧。
我确实看过this Stackoverflow question,但说实话我并不完全明白解决方案 - 尽管我在bin文件夹中似乎没有任何重复的dll。我真的认为这个问题在某处。
我已经双重检查了SQL查询,它们都返回数据。
有什么建议吗?我已经用完了!
编辑:
我已经设置了失败请求跟踪,并得到这个真正有用的结果:
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
是为/wastedropdown.asmx/getwaste和wastedropdown.asmx产生同样的错误/ getbintype
希望这对某人来说意味着什么!
EDIT2:
的代码在同一台服务器上不同的网站肯定能正常工作。我得到了提琴手出现以下错误:
{"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"}
帮助!