此处描述的处理程序处理来自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
下载捕获的方法。