Click here to Skip to main content
15,896,730 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


when I run my project and click on button at that time i want to capture current webpage and save as image in Folder. This is run succcessfully in localhost but when i publish project then it save Black Image instead of real image in server.

CopyFromScreen function gets error at runtime in server.
Error: The handle is invalid.
Posted
Updated 2-Apr-14 1:17am
v2

1 solution

You can't.
It appears to work in development because the client and the server are the same computer: so copying from the screen is possible.
If it worked in production, you would not get an image of the client display, you would get an image of the server display, which will not show any web pages.

And exactly what you would get would depend on what browser the client is using to display the webpage!

You cannot access the client screen for security reasons in 99.999% of cases - the exception being IE only, ActiveX controls allowed, ActiveX controls enabled - and since the last two are disallowed by default, and IE is a "minority" browser these days, you will almost certainly not be able to do this.

Think about it: if you could do it, so could malicious sites that want to track what you do, how you access your bank account, ...
 
Share this answer
 
Comments
Member 8825205 2-Apr-14 7:30am    
ok then tell me another way to capture screen.
I thought another way....
string aa = HttpContext.Current.Request.Url.AbsoluteUri;
Bitmap bmp = ClassWSThumb.GetWebSiteThumbnail(aa, 800, 600, 0, 0);
bmp.Save(Server.MapPath("thumbnail.bmp"));

Problem: i get url but it capture login page because i restrict than firstly login and then open so tell me solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900