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

StackOverflow https://stackoverflow.com/questions/20301871

  •  06-08-2022
  •  | 
  •  

Вопрос

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.

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.

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.

If I send 5000 sim numbers in http POST using jquery then the total size request sent is 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.

TRIED SOLUTION:

I tried to resolve the problem by editing httpRuntime configuration in web.config as follows

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.

ITENDED SOLUTION:

I think if I try to sync above httpRuntime element in Machine.config file as well then it work fine.

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:

$.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. and the after making this change second problem was due to long operation time the request was being interrupted by internet (network communication). I made sure I have reliable internet connectivity and tested it again and it worked.

BUT Now i am facing another problem. My httphandler send request to a webservice and I am getting following exception in response.

The operation has timed out
Это было полезно?

Решение

I have fixed the problem.

one problem was executionTimeout configuration in web.config. and the after making this change second problem was due to long operation time the request was being interrupted by internet (network communication). I make sure I have reliable internet connectivity and tested it again.

configured the webserivces as follows.

<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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top