Tuesday, April 16, 2013

Session_Start in Global.asax might be a good place to kick off the logic for a hits counter.

This came up as a challenge in an interview I had. From Session_Start one could see if a cookie was already set (flagging the browser/IP combo as already logged) and from there a database could be checked to see if the IP had already been logged. Fun stuff. I tried the following and was able to pull it off:

public class WebApiApplication : System.Web.HttpApplication
{
   protected void Session_Start()
   {
      HttpCookie cookie = new HttpCookie("foo");
   }
}

No comments:

Post a Comment