Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 663
  • Last Modified:

How can I scrape a rendered .aspx page and email it?

I wish to scrape whats rendered ona results page and email it.  This includes results from a form view, textbox controls, dynamically generated tables etc.  I basically want to do a screenshot or send the infiormation that is rendered as a text file.

I can scrape the page thus far, but not the rendered data.
0
devnewbee
Asked:
devnewbee
1 Solution
 
dineeshCommented:
Hi

Generate a PDF or an MDI and attach it to the email.

regards
Dinesh
0
 
urir10Commented:
Read this:
http://www.csharpfriends.com/Articles/getTip.aspx?articleID=210

This example is asking you for an input url but you can change it to take the current page. The code puts the whole page in the string variable which you can then email.
0
 
j_s_kelleyCommented:
I am not clear on exactly what you are looking for.  If you want the raw HTML, you need to look in the PreRender event for the page.  You can do this by overriding the Render method on the page.


        protected override void Render(HtmlTextWriter htmlWriter)
        {
            StringBuilder sb = new StringBuilder();
            HtmlTextWriter tw = new HtmlTextWriter(new System.IO.StringWriter(sb));
            base.Render(tw);
            string strHTML = sb.ToString();
 
            // Here you can do what you wish with the HTML
            htmlWriter.Write(strHTML);
        }

Open in new window

0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
devnewbeeAuthor Commented:
Here is my code for the finish button on this wizard.  I get this to work, but only scrapes the page and not the control values on the final step of the wizard.  
    protected void psWizard_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        {
            MailMessage mail = new MailMessage();
            mail.To = "test344@gmail.com";
            mail.From = "do-not-reply@gmail.com";
            mail.Subject = "this is a test email.";
            string url = "http://test.geopac.com/screen/";
            mail.Body = HttpContent(url);
            mail.BodyFormat = MailFormat.Html;
            mail.UrlContentBase = url;
            SmtpMail.SmtpServer = "relay.geopac.com";  
            SmtpMail.Send(mail);
        }
 
      
        dsInsert.Insert();
        Session["MyInsert"] = true;
        
    }
    private string HttpContent(string url)
    {
        WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
        StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
        string result = sr.ReadToEnd();
        sr.Close();
        return result;
        Response.Redirect("~/confirmation.aspx");
    }
}

Open in new window

0
 
devnewbeeAuthor Commented:
J_s_kelley:  I cane use the code above, but how do I call for it in the mail.body code of my mail code?
0
 
urir10Commented:
You cant call it you have to do it in the Render method of the page.
0
 
devnewbeeAuthor Commented:
Ok, so what happens is my user go through a wizard and the final page of the wizard display a results page based on some answers to dropdown etc on the page prior.  I just want to send that results information in an email once the user enters their email address in a textbox.

If I actually go to file and use save as (.txt) I see all of the results page formatted in a nice format (not real source).  This is kind of what I am looking for in that I want the user to either see a text file, and html file or a .pdf snapshot of the page as rendered once they click the finish button.
0
 
devnewbeeAuthor Commented:
Thanks urir.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now