Error when calling Flush method.
I receive an error when I called the Flush method.
The error is "Cannot close stream until all bytes are written"
This happens only if the character in stringbuilder is more than 10000 characters or so...
Any Ideas?
Public Sub CreateWebPage()
If _Response Is Nothing Then
Throw New Exception("Web response is set to nothing.")
End If
Dim stringbuilder As New System.Text.StringBuilder
stringbuilder.AppendFormat("<html><title>{0}</title><body>{1}</body></html>", _Title, WebPageBody)
With _Response
.ContentType = "text/html"
.ContentEncoding = Encoding.UTF32
.ContentLength64 = stringbuilder.Length
Try
Using writer As New StreamWriter(.OutputStream)
With writer
.Write(stringbuilder.ToString())
.Flush()
End With
End Using
Catch ex As Exception
Throw ex
Finally
.Close()
End Try
End With
End Sub
|