I am looking for a simple way to take a screenshot of an iFrame in my ASP page. I just couldn't achieve it with C# and I lack of knowledge of Javascript! Does anyone out there know the simple and best way to achieve this?
What I am trying to do is, I am building a website that students can log in to e-government website in my country and prove if they are continuing student with a single click so that they can get discount from our service.
Edit: The puzzle should be solved in local.
I am looking for a simple way to take a screenshot of an iFrame in my ASP page. I just couldn't achieve it with C# and I lack of knowledge of Javascript! Does anyone out there know the simple and best way to achieve this?
What I am trying to do is, I am building a website that students can log in to e-government website in my country and prove if they are continuing student with a single click so that they can get discount from our service.
Edit: The puzzle should be solved in local.
Share Improve this question edited Feb 20, 2012 at 14:30 Cute Bear asked Feb 20, 2012 at 14:19 Cute BearCute Bear 3,29113 gold badges47 silver badges70 bronze badges 1- Personally, I do not think a screenshot of an IFRAME is proof of much and would be significantly insecure as a concept of proving that a student is legitimate. I would advocate thinking up a different solution. – csharpnumpty Commented Feb 20, 2012 at 14:27
3 Answers
Reset to default 2this piece of code worked for me. I hope it does the same to the others.
private void saveURLToImage(string url)
{
if (!string.IsNullOrEmpty(url))
{
string content = "";
System.Net.WebRequest webRequest = WebRequest.Create(url);
System.Net.WebResponse webResponse = webRequest.GetResponse();
System.IO.StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
content = sr.ReadToEnd();
//save to file
byte[] b = Convert.FromBase64String(content);
System.IO.MemoryStream ms = new System.IO.MemoryStream(b);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
img.Save(@"c:\pic.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
img.Dispose();
ms.Close();
}
}
Unless I'm misunderstanding you, this is impossible.
- You cannot instruct the user's browser to take a screenshot (this would be a security risk … and has few uses cases anyway).
- You cannot load the page you want a screenshot of yourself (with server side code) because you don't have the credentials needed to access it.
server side Take a screenshot of a webpage with JavaScript?
javascript http://html2canvas.hertzen./