在asp.net C#网页截图 [英] Screenshot of webpage in asp.net c#

查看:175
本文介绍了在asp.net C#网页截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到网站的screeshot。问题是我在屏幕上的文本框。当我把截屏文本框的值不会出现。可有人指导我重新安排code。谢谢

 保护无效的button1_Click(对象发件人,EventArgs的发送)
{
    味精MAILMESSAGE新= MAILMESSAGE(txt_From.Text,txt_To.Text);
    尝试
    {
        msg.Subject = txt_Subject.Text;
        msg.Body =< BR />< B>的形式:其中; / B>中+ Form1中+< BR />< B>来源:< / B>中+ txt_From.Text + < BR />< b>向:LT; / b>中+ txt_To.Text +< BR />< BR />< BR />< BR />&LT ; b>名称:LT; / b><小时/>中+ TextBox1.Text +< BR />< BR />< B>日期:< / B>< BR /><小时/>< BR />中+ TextBox2.Text +< BR />< BR />中;
        msg.IsBodyHtml =真;
        WebRequest的mywebReq;
        WebResponse类mywebResp;
        StreamReader的SR;
        串strHTML中;
        StreamWriter的SW;        //把用户code到这里初始化页面        mywebReq = WebRequest.Create(HTTP://本地主机:4101 / WebForm2.aspx);
        mywebResp = mywebReq.GetResponse();
        SR =新的StreamReader(mywebResp.GetResponseStream());
        // SR =新的StreamReader(mywebResp.GetResponseStream(),System.Text.Encoding.ASCII);
        strHTML中= sr.ReadToEnd();
        SW = File.CreateText(使用Server.Mappath(Report.htm));
        sw.WriteLine(strHTML中);
        sw.Close();
        Response.WriteFile(使用Server.Mappath(Report.htm));        附件objAttachment =新的附件(@C:\\用户\\ 2714 \\文档\\ Visual Studio 2010的\\项目\\证书\\证书\\ Report.htm);
        msg.Attachments.Add(objAttachment);
        System.Net.Mail.SmtpClient objSmtpClient =新SmtpClient(10.238.52.200,25);
        objSmtpClient.Send(MSG);
    }
    赶上(异常前)
    {
        扔恩;
    }
}


解决方案

在您的网页捕获是合乎逻辑的看不到任何用户有它的类型 - 其实是不存在的,你只要把负荷页面,你期望看到的文本框?

如果您尝试获得调试理由的报告,你赢了,看在这个问题的时刻在页面上发生的事情,那么你需要使用建立一个JavaScript库(他能)页面的DOM和它发送给你。所有这些行动要求用户使他们 - 捕捉网页和电子邮件发送,即使你可以让它自动完成,如果他愿意为你展示他们有什么类型的用户必须嗤

一个例子 http://experiments.hertzen.com/jsfeedback/ 和库<一个HREF =htt​​p://html2canvas.hertzen.com/相对=nofollow> http://html2canvas.hertzen.com/ ,可以捕捉用户在屏幕上看到的东西。

相对的:<一href=\"http://stackoverflow.com/questions/2732488/how-can-i-convert-an-html-element-to-a-canvas-element/6789627#6789627\">How可我一个HTML元素转换为canvas元素?

I am getting the screeshot of the website. The problem is i have textboxes on the screen. When i take screen shot the values of textboxes are not appearing. Can someone guide me in rearranging the code. Thank you

protected void Button1_Click(object sender, EventArgs e)
{
    MailMessage msg = new MailMessage(txt_From.Text, txt_To.Text);
    try
    {
        msg.Subject = txt_Subject.Text;
        msg.Body = "<br /><b>form:</b> " + form1 + "<br /><b>From:</b> " + txt_From.Text + "<br /><b>To:</b> " + txt_To.Text + "<br /><br /><br /><br /><b>Name:</b><hr />" + TextBox1.Text + "<br /> <br /><b>Date:</b><br /><hr /><br />" + TextBox2.Text + "<br /><br />";
        msg.IsBodyHtml = true;
        WebRequest mywebReq;
        WebResponse mywebResp;
        StreamReader sr;
        string strHTML;
        StreamWriter sw;

        // Put user code to initialize the page here

        mywebReq = WebRequest.Create("http://localhost:4101/WebForm2.aspx");
        mywebResp = mywebReq.GetResponse();
        sr = new StreamReader(mywebResp.GetResponseStream());
        //sr = new StreamReader(mywebResp.GetResponseStream(), System.Text.Encoding.ASCII);
        strHTML = sr.ReadToEnd();
        sw = File.CreateText(Server.MapPath("Report.htm"));
        sw.WriteLine(strHTML);
        sw.Close();
        Response.WriteFile(Server.MapPath("Report.htm"));

        Attachment objAttachment = new Attachment(@"C:\Users\2714\Documents\Visual Studio 2010\Projects\Certificate\Certificate\Report.htm");
        msg.Attachments.Add(objAttachment);
        System.Net.Mail.SmtpClient objSmtpClient = new SmtpClient("10.238.52.200", 25);
        objSmtpClient.Send(msg);
    }
    catch (Exception ex)
    {
        throw ex;
    }    
}

解决方案

When you make a capture of the web page is logical to not see anything that the user have type on it - Actually is not exist, you just make a load of the page, what you expect to see on text boxes ?

If you try to get a report for debug reasons and you won to see what happens on the page at the moment of the issue then you need to use a javascript library that build (as he can) the dom of the page and send it to you. All this actions request the user to make them - to capture the web page and send it with email, even if you can make it automate, the user must deride if he like to show you what have type on them.

An example http://experiments.hertzen.com/jsfeedback/ and the library http://html2canvas.hertzen.com/ that can capture what the user see on screen.

relative : How can I convert an HTML element to a canvas element?

这篇关于在asp.net C#网页截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆