ממשק ה- API של ASP.NET של GrabzIt תומך גם באירועים, להלן דוגמה להקצאת מטפל ל- 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 points ל מטפל מוטבע ב GrabzIt DLL. אם זה לא נעשה כראוי, ScreenShotComplete
האירוע לא יפטר.
תזכור את זה תתקשר בחזרה לא יעבוד אם היישום שלך ממוקם באתר localhost.
<httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>