Asp.net 更改web.config中的maxJsonLength属性无效
我正在使用MS Virtual Earth AJAX控件在ASP.NET3.5站点的地图上绘制自定义边界。我有一个WCF服务,我从ASP.Net调用它来返回我需要绘制的点。在一个例子中,我需要绘制约40000个点 每当我需要绘制的点数(从WCF服务返回的行)超过25000时,就会出现以下错误 使用JSON JavaScriptSerializer进行序列化或反序列化时出错。字符串的长度超过了maxJsonLength属性上设置的值 我尝试将web.config中的maxJsonLength属性修改为2147483647,但更改此值无效。无论我将值设置为什么,当我尝试绘制25000多个点时,总是会出现错误。我甚至尝试将其设置为“ABC”,当我的WCF服务返回的记录不到25000条时,我的站点仍然可以工作 我验证了machine.config文件中没有maxJsonLength属性 下面是我的web.config文件的摘录:Asp.net 更改web.config中的maxJsonLength属性无效,asp.net,json,web-config,Asp.net,Json,Web Config,我正在使用MS Virtual Earth AJAX控件在ASP.NET3.5站点的地图上绘制自定义边界。我有一个WCF服务,我从ASP.Net调用它来返回我需要绘制的点。在一个例子中,我需要绘制约40000个点 每当我需要绘制的点数(从WCF服务返回的行)超过25000时,就会出现以下错误 使用JSON JavaScriptSerializer进行序列化或反序列化时出错。字符串的长度超过了maxJsonLength属性上设置的值 我尝试将web.config中的maxJsonLength属性修
*<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections><appSettings/>
<connectionStrings/>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"/>
</webServices>
</scripting>
</system.web.extensions>*
*
*
是否知道我对maxJsonLength属性所做的更改未被识别?此外,请将以下键添加到appSettings:
<appSettings>
<add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
...
</appSettings>
...
至少在Mvc中,此设置足以解决此问题。您可以尝试从WCF服务更改它
var jsonResult = Json(data, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
看见