API ASP.NET de GrabzIt también admite eventos, a continuación se muestra un ejemplo de asignación de un controlador a ScreenShotComplete
evento antes de que se llame a la captura de pantalla. Luego, una vez que se completa la captura de pantalla, el código dentro del grabzIt_ScreenShotComplete
método se llama.
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)); }
Finalmente configure el web.config para que GrabzIt.ashx points a la entrenador de animales incrustado en el GrabzIt DLL. Si esto no se hace correctamente, el ScreenShotComplete
El evento no será despedido.
Recuerda esto llamar de vuelta no funcionará si su aplicación se encuentra en localhost.
<httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>