GrabzIt's ASP.NET API ondersteunt ook evenementen, hieronder is een voorbeeld van het toewijzen van een handler aan de ScreenShotComplete
gebeurtenis voordat de screenshot wordt genoemd. Nadat de screenshot is voltooid, wordt de code binnen de grabzIt_ScreenShotComplete
methode wordt genoemd.
private GrabzItClient grabzIt = GrabzItClient.Create("Sign in to view your Application Key", "Sign in to view your Application Secret")%>"); protected void btnSubmit_Click(object sender, EventArgs e) { grabzIt.ScreenShotComplete += grabzIt_ScreenShotComplete; grabzIt.URLToImage("https://www.tesla.com"); //The below line specifies the GrabzIt.ashx handler inside the GrabzIt.dll grabzIt.Save(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) { GrabzItFile file = grabzIt.GetResult(result.ID); file.Save(Server.MapPath("~/results/"+result.Filename)); }
Configureer ten slotte de web.config zodat GrabzIt.ashx points naar de handler ingebed in de GrabzIt DLL. Als dit niet goed wordt gedaan, wordt de ScreenShotComplete
evenement wordt niet ontslagen.
Onthoud dit Bel terug werkt niet als uw toepassing zich op localhost bevindt.
<httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>