Method error 500 in cascadingdropdown WEB Service

Last post 03-13-2008 12:21 PM by fabiohiga. 6 replies.

Sort Posts:

  • Method error 500 in cascadingdropdown WEB Service

    01-31-2008, 1:50 PM
    • Member
      point Member
    • bnelcha
    • Member since 01-31-2008, 6:39 PM
    • Posts 3
      Hi Everybody. 
     
    I get a Method error 500 when i try to fill in CascadingDropDown more of 854 elements, with minus option will work fine, the shared function of web service work but when the code is execute i get this annoing error into the combo value, is possible to correct it? o you can suggest me a work-around solutions?
     
      Thanks ....
  • Re: Method error 500 in cascadingdropdown WEB Service

    01-31-2008, 2:00 PM
    Answer
    • Member
      612 point Member
    • jamesstill
    • Member since 04-27-2007, 4:57 PM
    • Portland, Oregon
    • Posts 82
    If the web service method is throwing a 500 then the error is originating from there and not your ASP.NET client with the DropDownList control. Can you post the stack trace and appropriate code samples? There's no way to know what's going on with the information you provided above.
    James Still
    SquareWidget LLC
    Handcrafted .NET Software
    http://www.squarewidget.com
  • Re: Method error 500 in cascadingdropdown WEB Service

    01-31-2008, 2:18 PM
    • Member
      point Member
    • bnelcha
    • Member since 01-31-2008, 6:39 PM
    • Posts 3

     

     

     Thank for you replay. but the error is just went the number of item in the array is more that 850 items,  I think that there is a limitation on the size of the retuning value or something like it.

     This is my web service

    [WebMethod]public List<CascadingDropDownNameValue> GetSubdivision(string knownCategoryValues, string category)

    {

    MySqlConnection con2 = new MySqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

    MySqlCommand cmd = new MySqlCommand();

    cmd.Connection = con;

    cmd.CommandText =
    "GetSubdivisiontmp";

    cmd.CommandType = CommandType.StoredProcedure;

    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    string countyId, str;

    if (!kv.ContainsKey("County"))

    {

    return null;

    }

    countyId = kv[
    "County"];

    if (countyId == "listing") countyId = "county";

    List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();using (con)

    {

    cmd.Parameters.AddWithValue(
    "?mkey", countyId);

    con.Open();

    MySqlDataReader dr = cmd.ExecuteReader();

    while (dr.Read())

    {

     

    values.Add(
    new CascadingDropDownNameValue((string)dr["Subdiv"],(string)dr["Subdiv"]));con.Close();

    }

    return values;

    }

  • Re: Method error 500 in cascadingdropdown WEB Service

    01-31-2008, 4:40 PM
    • Member
      612 point Member
    • jamesstill
    • Member since 04-27-2007, 4:57 PM
    • Portland, Oregon
    • Posts 82

    One thing I see right away is the call to con.Close() within the SqlDataReader enumeration. Get rid of that. When the connection goes out of scope after the using statement it will close the connection for you. I'm guessing that you're blowing the stack because the reader never finishes. You should explicitly close the reader or wrap it in a using statement:

    using (SqlDataReader dr = cmd.ExecuteReader()) {
        while (dr.Read()) {
            // fetch values from reader
        }
    } 
     
      
    James Still
    SquareWidget LLC
    Handcrafted .NET Software
    http://www.squarewidget.com
  • Re: Method error 500 in cascadingdropdown WEB Service

    01-31-2008, 5:01 PM
    • Member
      point Member
    • bnelcha
    • Member since 01-31-2008, 6:39 PM
    • Posts 3

    Thanks jame for you replay.

        I did what you sugested. but the  problem is the same.

      I don't know if i explain well my problem ,but the web service work just fine if the data i read from my database if less that 800 items.

       i got a category that have at less  23.000 item and my dropdown show the 500 error if i choice this category.

       I put   into my web service this statement and work fine

         
                cmd.Parameters.AddWithValue("?mkey", countyId);
    using (MySqlDataReader dr = cmd.ExecuteReader()){while (dr.Read())

    {

    str = (string)dr["SubDiv"];

     

    values.Add(new CascadingDropDownNameValue((string)dr["Subdiv"],(string)dr["Subdiv"]));

    if (dr.count > 500) return values;

     

    }

    }

    return values;

  • Re: Method error 500 in cascadingdropdown WEB Service

    02-06-2008, 2:02 AM
    Answer

    Hi Bnelcha,

    I think your database part is ok.  To return too many items once in an AsyncPostBack is not a good idea.  We suggest that you should limit its count or do other changes. 

    Best regards,

    Jonathan

     

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Method error 500 in cascadingdropdown WEB Service

    03-13-2008, 12:21 PM
    • Member
      2 point Member
    • fabiohiga
    • Member since 03-13-2008, 12:19 PM
    • Posts 1

    try to put it in your web.config

      <system.web.extensions>
        <scripting>
          <webServices>
            <jsonSerialization maxJsonLength="500000">
            </jsonSerialization>
          </webServices>
        </scripting>
      </system.web.extensions>
     
Page 1 of 1 (7 items)