We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

The message received from server could not be parsed.

Hi,
I developed export to excel file for one ASP.NET app. And i have following error:

The message received from server could not be parsed.

Code (in short):
byte[] file = new byte[500000];
...
using (SqlDataReader rr =
c.ExecuteReader(CommandBehavior.SingleRow))
{
rr.Read();
file = ((byte[])rr["EXPORT_EXCEL_TEMPLATE"]);
}

System.IO.FileStream fileStream = System.IO.File.Create(path);
fileStream.Write(file, 0, file.Length);
fileStream.Close();
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open(path);
IWorksheet sheet = workbook.Worksheets[0];


//FILLING EXCEL FILE


workbook.SaveAs("Soubor.xls", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);

And after that i see the error messsage.

When i use:

workbook.SaveAs("D:\\File.xls");

Everythink is OK, file is right and can be opened by MS Excel.

But when i use:

Response.Write(workbook);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=PorovUkazatelu.xls;");
Response.Charset = "windows-1250";
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1250);

Message is showen again.

So file is OK, but canot be sended via Response. Can somebody help me?



error_8badde5e.zip

3 Replies

YG Yavanaarasi G Syncfusion Team July 15, 2008 06:47 AM UTC

Hi Michal,

Thank you for your interest in Syncfusion products.

We suspect that the issue "The message received from the server could not be parsed" is due to you can't open an Excel file from within an Ajax update panel. This is because when you do an ASP.NET AJAX postback the return is parsed on the client by a Javascript code and different bits update different parts of your page. If the return is something that breaks the syntax ASP.NET AJAX is expecting you will get that error message. You can workaround this issue by setting EnablePartialRendering=false for ScriptManager.

Please refer the following link for more details.
http://forums.asp.net/p/1127991/1780067.aspx

Please try this and let me know if the problem still exists.

Regards,
G.Yavana



AD Administrator Syncfusion Team July 15, 2008 06:59 AM UTC



>Hi Michal,

Thank you for your interest in Syncfusion products.

We suspect that the issue "The message received from the server could not be parsed" is due to you can't open an Excel file from within an Ajax update panel. This is because when you do an ASP.NET AJAX postback the return is parsed on the client by a Javascript code and different bits update different parts of your page. If the return is something that breaks the syntax ASP.NET AJAX is expecting you will get that error message. You can workaround this issue by setting EnablePartialRendering=false for ScriptManager.

Please refer the following link for more details.
http://forums.asp.net/p/1127991/1780067.aspx

Please try this and let me know if the problem still exists.

Regards,
G.Yavana



Thank you very much, now it works fine!



YG Yavanaarasi G Syncfusion Team July 15, 2008 07:18 AM UTC

Hi Michal,

Thank you for your update.

Glad to hear that the problem has been solved.

Please let me know if you have any other concerns.

Regards,
G.Yavana


Loader.
Live Chat Icon For mobile
Up arrow icon