此處描述的處理程序處理來自GrabzIt屏幕快照Web服務的回調。 該處理程序的URL在以下位置傳遞給GrabzIt: callBackURL
的參數 Save 方法。
但是,只有在可以通過 Int以太網
如果要阻止對處理程序的所有訪問,除了GrabzIt之外,請使用此方法 安全技術.
要將處理程序添加到MVC項目中,只需在控制器中定義具有以下簽名的方法即可,如的SampleMVC項目所示。 ASP.NET演示.
然後將此方法的URL傳遞給GrabzIt,因此,如果它在Home控制器中,則回調URL可能類似於: http://www.example.com/Home/Handler
public ActionResult Handler(string filename, string id, string message, string customId, string format, int targeterror) { GrabzItClient grabzItClient = GrabzItClient.Create("Sign in to view your Application Key", "Sign in to view your Application Secret")%>"); GrabzItFile file = grabzItClient.GetResult(id); file.Save(Server.MapPath("~/results/" + filename)); return null; }
實現回調處理程序的最簡單方法是創建一個通用處理程序並從中繼承 GrabzIt.Handler
類,如下所示,然後實施 Process
方法。 此方法捕獲從GrabzIt服務傳遞給它的五個參數,包括捕獲到該捕獲對象的唯一ID。 GetResult 方法。
然後,此方法返回捕獲,即 saved在結果目錄中。 但是如果 null
值是從返回 GetResult 方法,這表明發生了錯誤。
public class OverridenHandler : GrabzIt.Handler { protected override void Process(HttpContext context, string filename, string id, string message, string customId, string format, bool targetError) { GrabzItClient grabzIt = GrabzItClient.Create("Sign in to view your Application Key", "Sign in to view your Application Secret")%>"); GrabzItFile file = grabzIt.GetResult(id); file.Save(context.Server.MapPath("~/results/" + filename)); } }
儘管上述技術使用了通用處理程序,但您可以輕鬆地使用ASPX頁面接收回調並下載捕獲。 為此,只需創建自己的ASPX頁面等,然後閱讀 詢問string 上面提到的參數。 最有用的參數是id參數,可與 GetResult
下載捕獲的方法。