Get Free Trial

Saving to server not working…

Jeremy Deats asked on March 22, 2016

Please advice on a solution. This example is provided to save to server in API documentation'myreport.xml', 'server', '', '');
We are attempting:'myreport.xml', 'server', '', 'http://ourserver:54422/savereport.aspx');
and flexmonster reports “error! can not save file”. The aspx page attempts to save the incoming HTTP post to a local file and has been tested. When running in a debug environment we can set a breakpoint and confirm http://ourserver:54422/savereport.aspx never gets called.

5 answers

Roman Petrusha Roman Petrusha Flexmonster March 22, 2016


Probably you have a security issue. Please check if CORS is enabled on your server.
I recommend you to use a tool like (Fiddle) to server’s response.

Jeremy Deats March 23, 2016

Thank you! It turned out to be CORS and another setting I had to change to allow ASP.NET to accept the request format. For other .NET developers I’ll share the web.conf changes I had to set in order to enable this. Now I have to figure out how to decompress the GZIP string
    <customErrors mode=”Off”/>
    <compilation debug=”true” targetFramework=”4.0″/>
    <!– requires because the Microsoft’s request objects don’t play friendly http post with header sequences they don’t reconize –>
    <httpRuntime requestValidationMode=”2.0″/>
    <!– validateRequest=”false” also added for this reason –>
    <pages validateRequest=”false” controlRenderingCompatibilityVersion=”3.5″ clientIDMode=”AutoID”/>
        <!– this enables CORS –>
        <add name=”Access-Control-Allow-Origin” value=”*” />
    <httpErrors errorMode=”Detailed”/>

Iryna Kulchytska Iryna Kulchytska Flexmonster March 23, 2016

Hi Jeremy,
Thank you very much for sharing web.conf for other .NET developers.
Please let us know if you need any further assistance.
Kind regards,

Jeremy Deats March 23, 2016

Thank you ira!
Also posting the C# ASP.NET source to handle the capture. I took this approach because I’m embedding in a WebForms project, but I hope someone finds this useful.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.IO.Compression;
using System.Text;

namespace FlexDemo
    public partial class CaptureDoc : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
                int lineCount = 0;
                StringBuilder sb = new StringBuilder();

                using (StreamReader sr = new StreamReader(Request.InputStream))
                    string line;
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)

                string xml = sb.ToString();
                string dxml = Server.UrlDecode(xml);

                // remove unwanted name-value pairs
                dxml = dxml.Replace(“name=myreport.xml&report=”, “”);
                dxml = dxml.Replace(“&type=xml”,””);
                // write report to hard drive
                System.IO.File.WriteAllText(@”c:\temp2\flex.xml”, dxml);

                Response.Write(“<response><status>Success</status><message>Wrote ” + lineCount.ToString() + ” lines</message></response>”);
            catch (Exception exc)

                Response.Write(“</response><status>Fail</status><exception>” + exc.Message.ToString() + “</exception></response>”);

Iryna Kulchytska Iryna Kulchytska Flexmonster March 24, 2016

Hi Jeremy,

Thank you so much for posting the solution. We really appreciate this and are happy that you are contributing to the knowledge around our component.

Thank you,

Please login or Register to Submit Answer