Errrr ... Use the .aspx page? What are handlers for?
You just need to create a generic base handler that takes care of serializing json (de) (e.g. using Json.net ) and then execute handlers for your ajax calls.
public abstract class JsonHandlerBase<TInput, TOutput> : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
TInput input = (TInput)context.Request;
TOutput output = ProcessRequest(context, parameter);
string json = (string)output;
context.Response.Write(json);
}
public abstract TOutput ProcessRequest(HttpContext context, TInput input);
public bool IsReusable { get { return false; } }
}
This is just an example, you decide if you need in your base handler.
source
share