response string is cut in 2033 characters when it is XML

2

I made a website with c # MVC that contains an ajax function that returns an xml, when I execute it in visual studio everything is fine, but when I put it in the iis the xml is cut in 2033 characters.

I already put this in the web.config and it does not work

<security>
    <requestFiltering>
       <requestLimits maxAllowedContentLength="500000000" />
    </requestFiltering>
</security>

<system.web>
   <httpRuntime maxRequestLength="500000000"  executionTimeout="120" />
</system.web>

And in the IIS

    
asked by Jorge Luis 04.10.2018 в 16:01
source

1 answer

2

The problem comes from the way in which the .NET connector communicates with the SqlServer.

Apparently, by some topic of the internal implementation of this, the XML responses are truncated to 2033 characters. What is done in these cases, is that the result is returned in several rows of 2033 characters maximum.

There are several solutions. The simplest is to use ExecuteXmlReader instead of ExecuteReader or ExecuteScalar .

Another option, given that the answer comes in several rows, would be to concatenate them all to obtain the complete xml, something similar to this:

string xml = "";
while (reader.Read())
{
    xml = xml + reader.GetString(0);
}

I do not know if in more modern versions of the .net connector this problem is solved, since the only reference I found is deleted from the Microsoft server, I put the link here using Wayback Machine

    
answered by 04.10.2018 в 17:48