mike55 Posted October 19, 2005 Posted October 19, 2005 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: ' 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. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted October 19, 2005 Administrators Posted October 19, 2005 http://www.xtremedotnettalk.com/showthread.php?t=78583 might be worth a read. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.