/ Published in: C#
Capture Web Screenshots easily with the [GrabzIt C# API](http://grabz.it/api/aspnet/).
This handy code snippet will fire a event when your screenshot is ready so that your code can process the screenshot anyway you wish!
You will need the free [GrabzIt Code Library](http://grabz.it/api/aspnet/download.aspx) to get started.
The code snippet assumes it is located within a ASPX page, in this example we are taking a screenshot of google.com.
This handy code snippet will fire a event when your screenshot is ready so that your code can process the screenshot anyway you wish!
You will need the free [GrabzIt Code Library](http://grabz.it/api/aspnet/download.aspx) to get started.
The code snippet assumes it is located within a ASPX page, in this example we are taking a screenshot of google.com.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* * The ASPX code behind */ //Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account! private GrabzItClient grabzIt = GrabzItClient.Create("APPLICATION KEY", "APPLICATION SECRET"); protected override void OnLoad(EventArgs e) { grabzIt.ScreenShotComplete += grabzIt_ScreenShotComplete; grabzIt.TakePicture("http://www.google.com", HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "GrabzIt.ashx"); } //The event method saves the screenshot protected void grabzIt_ScreenShotComplete(object sender, ScreenShotEventArgs result) { Image image = GrabzItClient.GetPicture(result.ID); image.Save(Server.MapPath("~/screenshots/"+result.Filename)); } /* *Add the following lines to your web.config. This allows the screenshot event to work */ <httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>
URL: http://grabz.it/api/aspnet/