When using server.execute
to capture the html of the current page the following code gets stuck in an infinite loop.
On Debug
Server.Execute
causes the button click event to fire each time. But why?
It appears that preserveForm = true
is maintaining the click event within the form but I need this to maintain my querystrings.
Protected Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
test()
End Sub
Protected Sub test()
Dim writer As TextWriter = New StringWriter()
Server.Execute("ThisPage", writer, True)
End Sub
I am aware I can do some kind or variable flag to check for the return of the loop but I want to know:
- Is this correct behaviour?
- Is so, why?
- Clean method to avoid the loop.
- Recommended alternate methods to capture entire page html.