Get a Free Trial

Callback Handler with ASP.NET

DownloadTechnical Information
ASP.NET API

Description

Having problems debugging your handler? Try the Callback Handler Test Tool.

The handler or web hook described here processes callbacks from the GrabzIt screenshot web service. The URL of this handler is passed to GrabzIt in the callBackURL parameter of the SaveAsync method. However this technique will only work if the handler is accessible via the Internet.

The following parameters are passed to the handler as GET parameters.

Remember callbacks will not work if your application is located on localhost.

If you want to block all access to the handler, except from GrabzIt then use this security technique.

Implementing a Callback Handler using MVC

To add a handler to a MVC project simply define a method with the following signature in a controller. Then pass the URL of this method to GrabzIt so if this is in the Home controller then the callback URL could look something like: http://www.example.com/Home/Handler

public async Task Handler(string filename, string id, string message, string customId, string format, int targeterror)
{
    //The client should be stored somewhere and reused!
    GrabzItClient grabzItClient = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret", client);
    GrabzItFile file = await grabzItClient.GetResultAsync(id);
    file.Save(Server.MapPath("~/results/" + filename));

    return null;
}

Other Techniques

While the above technique uses a generic handler, you can just as easily use a ASPX pagem or any other type of page. To recieve the callback and download the capture. To do this just create your own ASPX page etc and then read the querystring parameters mentioned above. The most useful parameter is the id parameter, which can be used with the GetResult method to download the capture.