Using the CallbackHandler Class for easy REST Callbacks

The CallbackHandler component is a server side component for very easily setting up JSON or XML callbacks.

You can use the CallbackHandler directly with any HTTP client or you can use ww.jquery.js and the ajaxCallMethod() function to send requests to the server. If you're using WebForms you can also use the AjaxMethodCallbackControl provided in the Westwind.Web.WebForms assembly.

The steps to do this are super simple:

  • Create an Http Handler (either standalone or .ASHX)
  • Inherit the handler from CallbackHandler
  • Create methods and mark them with [CallbackMethod]
  • Call the service with MyHandler.ashx?Method=x
  • Alternately using routing attributes to define a route

Callback methods can accept XML or JSON inputs and can generate XML or JSON output depending on the Accept type of the request. The default output type is JSON.



© West Wind Technologies, 1996-2016 • Updated: 12/19/15
Comment or report problem with topic