简体   繁体   English

无法使用jquery ajax调用(IIS 6)将冗长的JSON字符串发送到ASP.NET HttpHandler

[英]Unable to send lenghty JSON string to ASP.NET HttpHandler using jquery ajax call (IIS 6)

BACKGROUND: 背景:

I have an Http handler which receives SIM/CDMA numbers ('8953502103000101242') in json string format from jQuery Ajax call using http POST method to activate them on server. 我有一个Http处理程序,该处理程序使用Http POST方法从jQuery Ajax调用中以json字符串格式接收SIM / CDMA数字('8953502103000101242'),以在服务器上激活它们。

THE PROBLEM: 问题:

On Local Development Environment I can send up to 65K SIMS' Numbers (8953502103000101242 key/value pair in json string) BUT when I deploy to LIVE server then I faced the following problem. 在本地开发环境中,当我部署到LIVE服务器时,我最多可以发送65K SIMS的号码(json字符串中的8953502103000101242键/值对),但是我遇到以下问题。

If I send 2000 SIMS numbers separated by comma to Http handler then Http handlers receives http request successfully But when I send more than that (3000, 4000, 5000 SIM numbers in json string) then http request doesn't reach to HttpHandler at server even after few hours. 如果我将2000个SIMS编号以逗号分隔的方式发送给Http处理程序,则Http处理程序会成功接收到http请求,但是当我发送的请求数量更多(json字符串中的3000、4000、5000个SIM卡编号)时,http请求甚至无法到达服务器上的HttpHandler几个小时后。

If I send 5000 sim numbers in http POST using jquery then the total size request sent is 138.0 KB. 如果我使用jquery在http POST中发送5000个sim卡号,则发送的总大小请求为138.0 KB。 and it should be passed to server because server maxRequestLength is 2048576. but it is not being sent to server when we deploy it on live server and it work fine on local development environment. 并且应该将其传递给服务器,因为服务器的maxRequestLength是2048576。但是当我们将其部署到实时服务器上时,它不会发送到服务器,并且在本地开发环境中也可以正常工作。

TRIED SOLUTION: 尝试的解决方案:

I tried to resolve the problem by editing httpRuntime configuration in web.config as follows 我试图通过如下编辑web.config中的httpRuntime配置来解决问题

By using above httpRuntime configuration I noticed in Firefox firebug net state that It keeps waiting sending the request as executionTimeout="7200" but if executionTimeout="600" then it returns timeout error. 通过使用上述httpRuntime配置,我注意到Firefox firebug net状态中,它一直等待发送请求,执行状态为executeTimeout =“ 7200”,但是如果执行timeout =“ 600”,则它将返回超时错误。

ITENDED SOLUTION: 解决方案:

I think if I try to sync above httpRuntime element in Machine.config file as well then it work fine. 我认为,如果我也尝试在Machine.config文件中的httpRuntime元素上方进行同步,那么它将正常工作。

REQUIRED SOLUIOTN 所需溶液

WHAT CAN THE BE PROBLEM AND HOW TO RESOLVE IT. 有什么问题和解决方法。 PLEASE SUGGEST IN THIS REGARD. 请在此方面提出建议。 WAITING FOR A QUICK SOLUTION. 等待快速解决方案。

Jquery call to HttpHandler is as follows: 对HttpHandler的Jquery调用如下:

$.ajax({
                type: "POST",
                url: "../../HttpHandlers/PorthosCommonHandler.ashx",
                data: { order: JSON.stringify(orderObject), method: "ValidateOrderInput", orgId: sCId, userId: uId, languageId: lId },
                success: function(response) {
                    var orderResult = new dojo.data.ItemFileReadStore({
                        data: {
                            jsId: "jsorderResult",
                            id: "orderResult",
                            items: response.Data
                        }
                    });
});

UPDATE 更新

I have diagnosed the problem. 我已经诊断出问题了。 one problem was executionTimeout configuration in web.config. 一个问题是web.config中的executionTimeout配置。 and the after making this change second problem was due to long operation time the request was being interrupted by internet (network communication). 在进行此更改之后,第二个问题是由于操作时间较长,因此请求被Internet(网络通信)中断。 I made sure I have reliable internet connectivity and tested it again and it worked. 我确保我具有可靠的Internet连接,并再次对其进行了测试,并且该连接正常。

BUT Now i am facing another problem. 但是现在我面临另一个问题。 My httphandler send request to a webservice and I am getting following exception in response. 我的httphandler将请求发送到Web服务,并且正在响应以下异常。

The operation has timed out

I have fixed the problem. 我已经解决了这个问题。

one problem was executionTimeout configuration in web.config. 一个问题是web.config中的executionTimeout配置。 and the after making this change second problem was due to long operation time the request was being interrupted by internet (network communication). 在进行此更改之后,第二个问题是由于操作时间较长,因此请求被Internet(网络通信)中断。 I make sure I have reliable internet connectivity and tested it again. 我确保我具有可靠的Internet连接,然后再次进行测试。

configured the webserivces as follows. 如下配置Web服务。

<httpRuntime executionTimeout="7200" enable="true" maxRequestLength="2048576" useFullyQualifiedRedirectUrl="false" />

and

[WebMethod(Description = "Delete template",BufferResponse = false)]

Specifying "BufferResponse=false" indicates that .NET should begin sending the response to the client as soon as any part of the response becomes available, instead of waiting for the entire response to become available. 指定“ BufferResponse = false”表示.NET应该在响应的任何部分可用时立即开始将响应发送到客户端,而不是等待整个响应变得可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM