Free Support Forum -

Error with Response.End()


im using version
i build 2 types of documents (using the same code as in your examples)

the first doc only uses one datatable so uses:-


the second doc uses 3 datatables so uses:-


with the doc having the correct format for starting and ending tables

i am having problems with the 2nd method, the problem occurs at the very end of the process after it has collected all the data and then built the doc ready for display

'Stream the document to the client browser.
doc.Save( _
String.Format("{0}.doc", param), _
SaveFormat.FormatDocument, _
SaveType.OpenInBrowser, Response)


when it gets to Response.End() it errors with "Thread was being aborted"

any idea’s as to why?


Response.End does a Thread Abort. By design. From the documentation on MSDN:

"Calls to End, Redirect, and Transfer raise a ThreadAbortException when the current response ends prematurely."

so what would be causing it to end prematurly? and why does it only happen when i use ExecuteWithRegions

the dataset is setup as follows

dsResultSet.Tables(0).TableName = "Therapy"
dsResultSet.Tables(1).TableName = "Advice"
dsResultSet.Tables(2).TableName = "Client"

and populates fine

the doc template is as follows


–then all the cleint fields



–then all the advice fields



–then all the therapy fields


In your code, you have this line:


THAT is where the exception is taking place, if you are catching a Thread Abort exception.