Given the generic handler:
<%@ WebHandler Language="C#" Class="autocomp" %>
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
public class autocomp : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "application/json";
context.Response.BufferOutput = true;
var searchTerm = (context.Request.QueryString["name_startsWith"] + "").Trim();
context.Response.Write(searchTerm);
context.Response.Write(DateTime.Now.ToString("s"));
context.Response.Flush();
}
public bool IsReusable {
get {
return false;
}
}
}
How would I server side
cache this file for 1 hour based on the name_startsWith
query string parameter? With web user controls it's easy:
<%@ OutputCache Duration="120" VaryByParam="paramName" %>
But I've been looking around for a while to do the same with a generic handler (ashx
) file and can't find any solutions.