Programmatically get HTML of secure page

I've created a .aspx page that contains data populated from a Repeater control, and an 'Email' button that sends the current page as an HTML e-mail to the e-mail address input in a text box. Therefore, I need to extract the HTML of the current page and place it in a String variable, but I'm having a real tough time doing this.  My page exists in a secure site, so if you have navigated to the page in question, you are already logged in to the secure server.  A page created for a project similar to the one I'm working on uses something like this to get the HTML of the current, secure page (I didn't create that page). It used the following to extract the HTML:

Dim textWriter As TextWriter
Server.Execute("Page.aspx?queryParam1=" & sParam, textWriter)
Dim sHTML as String
sHTML = oTextWriter.ToString()
Dim email as SmtpClient 
...
...

Open in new window


However, even though this project is set up very similarly to mine, and is currently properly working,  my page hangs up when it makes a call to the Server.Execute method (Page.aspx is the current page containing the Email button).

I've tried a different way: Using HttpWebRequest and HttpWebResponse, and getting the HttpWebResponse.GetResponseStream.  However, what I found with this is that what is actually returned is the HTML for the Login Page to our server, NOT the current page's HTML.  Here is what I tried.

Dim oRequest as HttpWebRequest
Dim oResponse as HttpWebResponse
oRequest = WebRequest.Create(sCurrentPageUri)  'passed the current page's absolute uri
oRequest.Credentials = CredentialCache.DefaultCredentials ' ?
oResponse = oRequest.GetResponse()
Dim sReader as StreamReader = oResponse.GetResponseStream()
Dim sHTML as String = sReader.ReadToEnd()

Open in new window



Any comments on this would be appreciated. This is a first-time post, this site seemed like a great resource and that is exactly what I need right now. Something that I should be very simple has consumed much more time that I expected to figure out! If you need more details, please let me know. Thanks!
Pep_00Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CodeCruiserCommented:
As its the current page, try Page.Render method to get the HTML

http://msdn.microsoft.com/en-us/library/20b8wk8d.aspx
0
Pep_00Author Commented:
Medo, thanks for the comment, but I think that the link demonstrates sort of what I am doing in the second snippet, where I am not getting the current page's HTML, but rather the HTML of the login page for the secure server (unless I'm missing something subtle).  I am perhaps not doing something correctly with the credentials of the request.  CodeCruiser, thank you for the reply - I am relatively new to .NET, and didn't know about Page.Render method, but I think that is what I need. Thanks!
0
Amandeep Singh BhullarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.