wwHoverPanel |
How wwCallbackHandler works |
When you implement your handler, make sure you remove your base handler implementation ProcessRequest method or call base.ProcessRequest to ensure the base behavior is fired.
<%@ WebHandler Language="C#" Class="Handler" %> using System; using System.Web; using System.Web.SessionState; using Westwind.Web.Controls; public class Handler : Westwind.Web.Controls.wwCallbackHandler // , IRequiresSessionState { [CallbackMethod] public string HelloWorld(string Name) { return "Hello " + Name + "! Time is: " + DateTime.Now; } [CallbackMethod] protected decimal AddNumbers(decimal x, decimal y) { return x + y; } }
Note that if you require session state you'll need to enable the IRequiresSessionState interface explicitly. In service scenarios this usually shouldn't be required.
To assign the handler type use the TargetCallback property of the wwMethodCallback control and assign it the type of the handler:
protected void Page_Load(object sender, EventArgs e) { // *** Must assign the target type for the callback control // *** otherwise it can't create the proxy this.Callback.TargetCallbackType = typeof(Handler); }
This property must be set in code and cannot be set via markup since an actual type instance is required.
To create a standalone Http Handler, create a class and inherit from wwCallbackHandler. Then register the class in web.config as an Http Handler:
<httpHandlers> <add verb="*" path="MyService.axd" type="Westwind.Web.Samples.CallbackHandler,WebSamples" /> </httpHandlers>
(in IIS 7 Integrated mode use the <handlers> section instead).