Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
Using WebRequest to get the rendered HTML of protected page, returns login page
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="tjd1981" data-source="post: 3511654" data-attributes="member: 40369"><p><strong>Don't use WebRequest to render your own HTML. Just override the render sub routine</strong></p><p></p><p>To output the HTML from your page with out calling it a second time you just need to override the render subroutine. The example function below is called when the page is rendered and should be added to your page's code behind file.</p><p></p><p> Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter)</p><p> Dim sbOut As New StringBuilder()</p><p> Dim swOut As New IO.StringWriter(sbOut)</p><p> Dim htwOut As New HtmlTextWriter(swOut)</p><p> MyBase.Render(htwOut)</p><p> Dim sOut As String = sbOut.ToString()</p><p> writer.Write(sOut)</p><p> End Sub</p><p></p><p>The 'sOut' variable is your HTML string you will need to write to a file and save and if you have any javascript in it you should probably run through a few regular expressions to strip them out before writing to file. Hope this helps. Good luck.</p></blockquote><p></p>
[QUOTE="tjd1981, post: 3511654, member: 40369"] [b]Don't use WebRequest to render your own HTML. Just override the render sub routine[/b] To output the HTML from your page with out calling it a second time you just need to override the render subroutine. The example function below is called when the page is rendered and should be added to your page's code behind file. Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter) Dim sbOut As New StringBuilder() Dim swOut As New IO.StringWriter(sbOut) Dim htwOut As New HtmlTextWriter(swOut) MyBase.Render(htwOut) Dim sOut As String = sbOut.ToString() writer.Write(sOut) End Sub The 'sOut' variable is your HTML string you will need to write to a file and save and if you have any javascript in it you should probably run through a few regular expressions to strip them out before writing to file. Hope this helps. Good luck. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
Using WebRequest to get the rendered HTML of protected page, returns login page
Top