AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

AdvantageHandler Class

Abstract base class for ACSP HTTP handlers that supports routing, AJAX method invocation, automatic content-type negotiation, and HTTP verb filtering via attributes. Implements the RouteBase Implements the IHttpHandler Implements the IRequiresSessionState

Namespace:  AdvantageCMS.Core.Common.BaseClasses.Handler
Assembly:  AdvantageCMS.Core (in AdvantageCMS.Core.dll)

Syntax


[HttpPostAttribute]
public abstract class AdvantageHandler : RouteBase, 
	IHttpHandler, IRequiresSessionState, IDisposable

Examples


The following example shows how to create a custom HTTP handler by inheriting from AdvantageHandler. Override the HTTP verb methods to handle requests, then register the handler as a route during application startup.
C#
// 1. Define a custom handler public class ProductHandler : AdvantageHandler {     public override object GET()     {         int domainId = CurrentDomain.DomainID;         var products = ModuleEngine.GetAllPublishedObjects<Product>();         return new { success = true, data = products };     }     public override object POST()     {         string name = context.Request["name"];         string sku = context.Request["sku"];         // persist via ModuleEngine / CurrentSql         return new { success = true, message = "Product created" };     } } // 2. Register the route in Global.asax or RouteConfig RouteTable.Routes.Add(new GenericHandlerRoute<ProductHandler>("api/products"));

Inheritance Hierarchy


Object
  RouteBase
    AdvantageCMS.Core.Common.BaseClasses.Handler..::..AdvantageHandler