GrabzIt في ASP.NET API يدعم أيضًا الأحداث ، فيما يلي مثال على تعيين معالج إلى ScreenShotComplete
حدث قبل لقطة الشاشة. ثم بمجرد اكتمال لقطة الشاشة الرمز داخل grabzIt_ScreenShotComplete
طريقة تسمى.
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)); }
أخيرًا قم بتكوين web.config بحيث يكون GrabzIt.ashx pointليالي إلى معالج مضمن في GrabzIt DLL. إذا لم يتم ذلك بشكل صحيح ScreenShotComplete
لن يتم إطلاق الحدث.
تذكر هذا رد لن يعمل إذا كان تطبيقك موجودًا على المضيف المحلي.
<httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>