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到 处理器 嵌入 抓取DLL。 如果执行不正确, ScreenShotComplete
事件不会被触发。
记住这一点 回电话 如果您的应用程序位于localhost上将不起作用。
<httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>