In my current C# web application I request a JSON object from a WebMethod, this JSON object exceeds the maximumJSONLength. And results in:
在我当前的C#Web应用程序中,我从WebMethod请求一个JSON对象,这个JSON对象超过了maximumJSONLength。并导致:
InvalidOperationException: The length of the string exceeds the value set on the maxJsonLength property.
InvalidOperationException:字符串的长度超过maxJsonLength属性上设置的值。
My current solution has been to raise the maxJsonlength
(in the Web.config) above the JSON length of the object, but now that I am migrating my application over to Windows Server (Which does not seem to support this override). Is there a way to send the JSON object through an ajax POST in parts? If so what is the best solution, I have searched for a way to send the data in multiple parts but there is no clear solution.
我目前的解决方案是将maxJsonlength(在Web.config中)提升到对象的JSON长度之上,但现在我将我的应用程序迁移到Windows Server(似乎不支持此覆盖)。有没有办法通过ajax POST部分发送JSON对象?如果是这样,什么是最好的解决方案,我已经搜索了一种方法来发送多个部分的数据,但没有明确的解决方案。
1 个解决方案
#1
0
This is not a solution that works with out editing the maxJsonLength, but it allows maxJsonLength to be modified in Windows Server.
这不是一个无需编辑maxJsonLength的解决方案,但它允许在Windows Server中修改maxJsonLength。
Adding the following to my web.config allowed me to then edit the maxJsonLength.
将以下内容添加到我的web.config允许我编辑maxJsonLength。
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
...
</configuration>
I hope this helps anyone else coming a similar problem.
我希望这可以帮助其他人遇到类似的问题。
#1
0
This is not a solution that works with out editing the maxJsonLength, but it allows maxJsonLength to be modified in Windows Server.
这不是一个无需编辑maxJsonLength的解决方案,但它允许在Windows Server中修改maxJsonLength。
Adding the following to my web.config allowed me to then edit the maxJsonLength.
将以下内容添加到我的web.config允许我编辑maxJsonLength。
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
...
</configuration>
I hope this helps anyone else coming a similar problem.
我希望这可以帮助其他人遇到类似的问题。