我已經有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"}
幫助!