Exception saving to HttpResponse

I’m trying to save a simple “hello world” workbook to an HttpResponse, but always get an exception.

My code is:

Dim wb As New Workbook()
Dim sheet As Worksheet = wb.Worksheets(0)
Dim cell As Cell = sheet.Cells(“A1”)
cell.PutValue(“Hello World!”)
wb.Save(“Test.xls”, FileFormatType.Default, SaveType.OpenInBrowser,
Response)
all in a button click event handler.

but this gives the exception:
"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near ‘’"
This is using the evaluation version of Aspose.cells v4.4.0.5 for .NET 2.0.

What am I doing wrong?
Hi,

Well, I tested your code and it works fine. I don't find any problem running on .NET 2.0. Do you use some sort of Http Compression or other utilities/settings on IIS.

Could you try the following code:

Dim wb As New Workbook()
Dim sheet As Worksheet = wb.Worksheets(0)
Dim cell As Cell = sheet.Cells("A1")
cell.PutValue("Hello World!")
Dim stream As MemoryStream = New MemoryStream()
wb.Save(stream, FileFormatType.Default)
response.ContentType = "application/vnd.ms-excel"
'This is same as OpenInBrowser option
response.AddHeader( "content-disposition","inline; filename=Test.xls");
response.BinaryWrite(stream.ToArray())
response.End()

For further reference, please check:

Thank you.

I tried your code, but I get the error

msxml3.dll: System error: -1072896748.
in this function from ScriptResource.axd - (whatever that it)
function Sys$Net$XMLHttpExecutor$get_responseData() {
///
if (arguments.length !== 0) throw Error.parameterCount();
if (!this._responseAvailable) {
throw
Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse,
‘get_responseData’));
}
if (!this._xmlHttpRequest) {
throw
Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler,
‘get_responseData’));
}
return this._xmlHttpRequest.responseText;
}
The error occurs on the red line.

I’ve just looked through IIS, and can see that there is a Compression ISAPI Filter installed. I’ve just removed it, but still get the same problem with my original code.

BTW, One of those links suggested this was an IE6 problem, but a colleague just tested my original code in IE7, and got the same exception.

Thanks,
Simon

My apologies. The problems seems to be caused by having an update panel around the download button. Once I remove the update panel, it all works fine.

Thanks!