When a user double-clicks on a table row, my ASP.NET 4.5
.asmx web service
(part of a web forms project, not separated) returns an xml string
so that the details for that specific row can be retrieved from the database.
Initially, this process works well.
However, in cases where the response is lengthy (around 200k to 300k character count), the web page displays a JavaScript alert popup (with the message "Error") and shows a 500 Internal Server Error
in the Chrome console
, without any further information. Interestingly enough, when I manually input the arguments into the web method URL, I receive an immediate and complete xml string response with no problems.
I am utilizing the following (synchronous) javascript/ajax code to invoke the web method:
function GetDetailsFromTableRow(userID, country, rowName) {
var url = "http://MyServer/MyWebService.asmx/MyWebMethod",
result = '';
$.ajax({
type: "POST",
async: false,
url: url,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
'userID': userID,
'country': country,
'rowName': rowName
}),
success: function (response) {
result = response.d;
},
error: function (x, t, m) {
if (t === "timeout") {
alert('timeout!');
}
else {
alert(t); //<- this gets thrown apparently
}
}
});
return result;
}
Based on this javascript, it appears that the issue is not related to a timeout error, ruling out one possibility.
Moreover, I would assume that I shouldn't have to chunk the response myself for a dataset that is only a few hundred kilobytes in size, but there may be factors I'm overlooking.
While I understand that asynchronous calls are generally preferred, I have successfully handled other substantial data requests (both asynchronously and synchronously). Therefore, I seek an explanation as to why this approach fails for larger responses (some responses are 80kB and others exceed 200kB, with only the former functioning properly) since there seems to be a missing piece in my understanding of the situation.
For the sake of completeness: making an async=true
call to the web service yields the same outcome.