Hi,
I am executing the following method which save a copy of a page to the web server that can then be emailed to a user:
A problem occures when I exit the method and return the to the method that called it. The exception that I am gettings is a ThreadAbortException. Any suggestions on what can cause this or how to prevent it occuring.
Mike55.
I am executing the following method which save a copy of a page to the web server that can then be emailed to a user:
Code:
' This method saves a copy of this page to a particular location on the web server. This copy
' is then accessed by when the email is generated and sent to the administrator of the system.
Private Sub saveReceipt()
Dim csReg As New clsReg
Dim outputFileName As String = dstDataset.Tables("Organization").Rows(0).Item(0).ToString() + ".Html"
Dim outputFileLocation As String = csReg.readReg("Software", "SureTxt", "ReceiptPath")
Dim renderedOutput As StringBuilder
Dim writer As StringWriter
Dim htmlWriter As HtmlTextWriter
Dim outputStream As FileStream
Dim writerStream As StreamWriter
Dim filename As String
Dim nextPage As String
Try
' create a HtmlTextWriter to use for rendering the page
renderedOutput = New StringBuilder
writer = New StringWriter(renderedOutput)
htmlWriter = New HtmlTextWriter(writer)
' render the page output
Page.RenderControl(htmlWriter)
' save the rendered output to a file
filename = outputFileLocation & outputFileName
outputStream = New FileStream(filename, FileMode.Create)
writerStream = New StreamWriter(outputStream)
writerStream.Write(renderedOutput.ToString())
writerStream.Flush()
Catch ex As Exception
Throw ex
Finally
'clean up
If (Not IsNothing(outputStream)) Then
outputStream.Close()
End If
If (Not IsNothing(htmlWriter)) Then
htmlWriter.Close()
End If
If (Not IsNothing(writer)) Then
writer.Close()
End If
End Try
' Redirect the user to the welcome page.
Response.Redirect("Welcome.aspx")
End Sub
A problem occures when I exit the method and return the to the method that called it. The exception that I am gettings is a ThreadAbortException. Any suggestions on what can cause this or how to prevent it occuring.
Mike55.