0

I am uploading .xml file but getting error 'System.OutOfMemoryException' on ds.GetXml(); in asp.net with C#.

small .xml file is working fine but big file not. i am trying with 60 mb file but it failed and getting memory exception on ds.GetXml() method.

Detail view : System.OutOfMemoryException: The function evaluation was disabled because of an out of memory exception.

DataSet dsCompendium = General.getDataSet4mXML(strFilePath,strFileName); 
// this is custom function to get dataset from XML : getDataSet4mXML(string,string)
DataTable dtCompendium = dsCompendium.Tables[1];
strXML = dsCompendium.GetXml();

<httpRuntime targetFramework="4.5.1" maxRequestLength="1048576" />     

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

help me out

2
  • 1
    can you post your code? Commented Jun 23, 2016 at 6:19
  • inserted code..getting error over here.. Commented Jun 23, 2016 at 6:30

3 Answers 3

0

See the values for maxRequestLength value of httpRunTime in web.config. Try changing it to a bigger number.

Sign up to request clarification or add additional context in comments.

2 Comments

maxRequestLength="314572800"
I go with this link: stackoverflow.com/questions/33921019/… and work perfectly.. i change project properties iis express to local iis than work perfectly...
0

It seems like HTTP web request size is exceeding in your case.

The 4MB default is set in machine.config, but you can override it in you web.config. For instance, to expand the upload limit to 20MB, you'd do this:

<system.web>
  <httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>

Edit

For IIS7 and above, you also need to add the lines below:

 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

Note: maxAllowedContentLength is measured in bytes

4 Comments

<httpRuntime targetFramework="4.5.1" maxRequestLength="314572800" />
Have you checked request limit at IIS end?
This link will help you out to check same.
This configuration not work on iis express on vs2013 project properties. when i change project properties => web => server => IIS Express to Local IIS it work perfectly but not working on iis express. But Question is why not on iis express on i.e. localhost: 1202 this still not solved. any idea about this @geekyninja.
0

Try to use DataSet ReadXml(XmlReader) method.

To create XmlReader

FileStream st = File.Open(@"filepath", FileMode.Open);
XmlReader reader = XmlReader.Create(st);  
DataSet ds = new DataSet();  
ds.ReadXml(reader);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.