12 events or so. Since I don't need the full power, and resource consumption, of an aspx page, an HTTPHandler seemed like a good idea.
It's actually quite easy to create an HTTPHandler in .Net. This shows how to integrate a single HTTPHandler into an existing .Net 4.5 project using VS2012.
The first step is to create a .cs class which implements IHttpHandler, mine is named Heartbeat.cs:
using System;
using System.Web;
namespace MyNamespace
{
public class Heartbeat : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.Write("Hi There!");
}
}
}
The second step is to create a .ashx page with one line. Here's my Heartbeat.ashx page:
<% @ WebHandler language="C#" class="SurveyDirector.Heartbeat" codebehind="Heartbeat.cs" %>
And you are done.
Now entering the URL
http://127.0.0.1/MyProject/Heartbeat.ashx
I get
Hi There!
Done.