AJAXTOOLKIT: CascadingDropDownList, [Error 500]
Salve desenvolvedores,
Para quem já está trabalhando com o AJAX Extension 1.0 e AJAXTOOLKIT, pode ter notado um erro quando utilizamos o controle CascadingDropDownList e nosso método Web retorna uma lista CascadingDropDownNameValue acima de 982 itens. Este problema ocorre pois há limite padrão na conversão JSON.
Pois bem, para arrumar, não é difícil. Mãos à massa.
Em cima da declaração da classe pública WebService, adicione a linha:
[System.Web.Script.Services.ScriptService()]
Exemplo:
[System.Web.Script.Services.ScriptService()]
public class wsGeral : System.Web.Services.WebService {
Depois, vamos adicionar algumas seções no Web.Config e o novo parametro JSON.
Dentro da Seção configuration, adicione:
<configSections>
<sectionGroup name=”system.web.extensions” type=”System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″>
<sectionGroup name=”scripting” type=”System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″>
<section name=”scriptResourceHandler” type=”System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ requirePermission=”false” allowDefinition=”MachineToApplication”/>
<sectionGroup name=”webServices” type=”System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″>
<section name=”jsonSerialization” type=”System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ requirePermission=”false” allowDefinition=”Everywhere”/>
<section name=”profileService” type=”System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ requirePermission=”false” allowDefinition=”MachineToApplication”/>
<section name=”authenticationService” type=”System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ requirePermission=”false” allowDefinition=”MachineToApplication”/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
e novamente dentro de configuration, adicione:
<system.web.extensions>
<scripting>
<webServices>
<!– Uncomment this line to customize maxJsonLength and add a custom converter –>
<jsonSerialization maxJsonLength=”5000000″ />
<!– Uncomment this line to enable the authentication service. Include requireSSL=”true” if appropriate. –>
<!–
<authenticationService enabled=”true” requireSSL = “true|false”/>
–>
<!– Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
writeAccessProperties attributes. –>
<!–
<profileService enabled=”true”
readAccessProperties=”propertyname1,propertyname2″
writeAccessProperties=”propertyname1,propertyname2″ />
–>
</webServices>
<!–
<scriptResourceHandler enableCompression=”true” enableCaching=”true” />
–>
</scripting>
</system.web.extensions>
Pronto!
abraços,