2013-05-08 112 views
0

我已经有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"}

帮助!

回答

0

我发现这是下降到使用,然后与一些IIS发生冲突骆驼的方法名称答案重写代码以确保网址为小写。

这是通过使用Fiddler,这是我的耻辱,从未使用过。我现在是一个完全转换!

0

我找到的方法500只是由于代码或数据库安全权限设置不正确而导致的。因此,请确保您的数据表正在返回数据(例如,IIS应用程序池是否具有正确的权限并确保您的KnownCategoryvalues(例如bPLUID的值)和类别(例如,Bintype)是正确的,在dr["bT"].ToString()r["bPLUID"].ToString()));中是正确的。检查两种Web方法。

您可以通过调用来测试Web方法。获得浪费应该不需要价值。 getBinWaste可能会将已知类别值= bPLUID:[在此处输入一个id值]类别bintype。

令人生气,但最终确实奏效。

0

我有同样的问题。在我安装其他角色服务后,Tt工作停止。然后,我头昏脑胀了几个小时后,发现在站点的Handler Mappings中,* .asmx的一个脚本方法的版本号错误!查找公共标记:B03F5F7F11D50A3A,如果您看到2.0.0.0版,请删除它。而已。

1

我认为这是因为你得到的数据太大。你必须将以下代码添加到你的web.config:

<system.web.extensions> 
    <scripting> 
     <webServices> 
      <jsonSerialization maxJsonLength="5000000" /> 
     </webServices> 
    </scripting> 
</system.web.extensions> 

问候