XMLHttpRequest responseText is truncated or not returned when return large amounts of data


I am developing a web solution that will use javascript to call a WCF Restful service. The javascript is stored in a normal Html page.
I use XMLHttpRequest to send the request to the WCF service and use the responseText from the XMLHttpRequest object to parse the response from the WCF Post.
However if the WCF returns to much information I will get a 12152 status from the XMLHttpRequest object.
Attached is a zip file that contains the following:
1. A SQL script
2. A VS 2010 project

Please do the following steps before opening the VS project:
1. Open the "Create Store Table.sql" script, create a database and run this script, it will create a store table and populate it with 10,000 rows (the script was created and run on SQL server 2008R2)
2. "WCFPoc.sln" this is a VS 2010 project, the file "WCFPoc\Store.svc.cs" needs to be renamed to "WCFPoc\Store.svc" as the upload doesn't except file extensions of .svc
3. In "WCFPoc\App_Data\IStore.cs" the connection string in the GetStores function needs to be set to the DB used where the script in step 1 was run.

Please open the project when the above steps have been completed, the following steps describe the issue that I really need to fix:
1. Select the "SearchStores.htm" file and run the project.
2. Click on one of the buttons in the htm page (do not enter any text in the text boxes)
3. The Results Text box will appear with "Status:12152 Text:Unknown" these is the XMLHttpRequest status code returned when there is to much information.
4. Open "App_Data\IStore.cs" and uncomment the line "//string sql = " and comment the line below this in the GetStores function.
5. Do step 1 & 2 again
6. The reponseText from the XMLHttpRequest object contains valid information.

I have tried a number of different things, but none have helped.
In the Web.config I changed transferMode="Buffered" to transferMode="Streamed", this does return reponseText, however the text is truncated and does not contain all the return information.
I suspect it's nothing to do with the WCF as I have set the maxReceivedMessageSize to 2,147,483,647, I have also set the maxStringContentLength to large number, but they do not effect the results in any way.

Any ideas would be of great help.
Who is Participating?
As far as the error code goes, this might shed some light into the mystery:

As for "However if the WCF returns to much information"
Why don't you rethink your strategy. It's not clear to me how you intend to use the data returned by the server, but if upon page load you are retrieving 10000 items to populate a SELECT list, as an end-user, I can't imagine scrolling/reading 10000 items just to select one (or a few).  A better approach would be to implement an autosuggest. Basically you present the user with a text field where s/he begins typing and say after the 3rd character you send an ajax request to the server so that it sends you only the items whose name start with those three characters. This should reduce the number of results you get at once.  It seems more practical and resource efficient.

Now, if you REALLY want all those 10000 records, see if there is a way to increase the memory limit and/or the script execution time.
AdvocoAuthor Commented:
Increasing points for question
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.