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.HandlerAssembly: AdvantageCMS.Core (in AdvantageCMS.Core.dll)
Syntax
[HttpPostAttribute] public abstract class AdvantageHandler : RouteBase, IHttpHandler, IRequiresSessionState, IDisposable
Examples
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"));
