Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...