<%@ WebHandler Language="C#" Class="image" %> using System; using System.Web; using System.Diagnostics; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Drawing; public class image : IHttpHandler { public String connString = ConfigurationManager.ConnectionStrings["SQLConnectionString"].ToString(); #region callStoredPRoecdure Facades ============================================= private DataSet callStoredProcedure() { dal comDal = new dal(); return comDal.RunProcedure(); } private DataSet callStoredProcedure(string storedprocedures) { dal comDal = new dal(storedprocedures); return comDal.RunProcedure(); } private DataSet callStoredProcedure(string storedprocedures, SqlParameter[] parameters) { dal comDal = new dal(storedprocedures, parameters); return comDal.RunProcedure(); } private DataSet callCommand(string commandString) { dal comDal = new dal(); return comDal.RunCommand(commandString); } #endregion public int RiaId = -1; public string additionalInfo = ""; public string referrerURL = ""; public string browserCaps = ""; // The following binary data represents a 1x1 transparent pixel private static readonly byte[] _imageData = new byte[] { 0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0x80,0x00, 0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x21,0xF9,0x04,0x01,0x14, 0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00, 0x00,0x02,0x02,0x44,0x01,0x00,0x3B }; public void ProcessRequest(HttpContext context) { processLog(); context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.AddHeader("Pragma", "no-cache"); context.Response.Expires = -1; context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(_imageData); /* Image pict2 = Image.FromFile("blank.gif");//http://analytics.mediaforge.com/images/blank.gif"); pict2. context.Response.ContentType = "image/jpeg"; pict2.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); //*/ Debug.WriteLine("process data here"); } public string getBrowserCaps() { string browserString1 = ""; HttpBrowserCapabilities bc = HttpContext.Current.Request.Browser; browserString1 += "platform:" + bc.Platform + ";"; browserString1 += "javascript:" + bc.EcmaScriptVersion + ";"; browserString1 += "browser:" + bc.Browser + ";"; browserString1 += "version:" + bc.Version + ";"; return browserString1; } public void processLog() { try { RiaId = Int32.Parse(HttpContext.Current.Request.QueryString["RiaId"]); } catch { RiaId = -3002; } try { additionalInfo = HttpContext.Current.Request.QueryString["additionalInfo"]; } catch { additionalInfo = ""; } try { browserCaps = HttpContext.Current.Request.QueryString["browserCaps"]; } catch { Debug.WriteLine("in here"); browserCaps = getBrowserCaps(); } if (additionalInfo == "" || additionalInfo == null) { additionalInfo = ""; } if (browserCaps == "" || browserCaps == null) { browserCaps = getBrowserCaps(); } Debug.WriteLine("browserCaps = " + browserCaps); /* try { referrerURL = HttpContext.Current.Request.UrlReferrer.ToString(); } catch { referrerURL = ""; } //*/ //?RiaId=10&additionalInfo=testFromTheUrl SqlParameter[] parameters = { new SqlParameter("@riaID", SqlDbType.BigInt), new SqlParameter("@additionalInfo", SqlDbType.NVarChar, -1), new SqlParameter("@browserCaps", SqlDbType.NVarChar, -1) }; parameters[0].Value = RiaId; if (additionalInfo != null && additionalInfo != "") { parameters[1].Value = additionalInfo; } else { parameters[1].Value = ""; } parameters[2].Value = browserCaps; callStoredProcedure("s_tPixelLogs__Insert", parameters); } public bool IsReusable { get { return false; } } } /* * * int clientID; try { clientID = Int32.Parse(Request.QueryString["cid"]); } catch { clientID = 6;// 3;// 0; } //*/ //tTestData_ZidoLogs //s_tTestData_ZidoLogs__Insert