This document describes how to calculate the number of visitors on a static html page.
- Static Page staticHtml.html
- <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "
- <Html xmlns = "
- <Head>
- <Title> several methods for collecting dynamic page access volume </title>
- </Head>
- <Body>
- This is displayed in the layer
- <Div id = "pv"> </div>
- <Script src = "act. aspx"> </script>
- </Body>
- </Html>
- Accumulate page act. aspx
- <% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "act. aspx. cs" Inherits = "AddNumber" %>
- Act. aspx. cs
- Code
- Public partial class AddNumber: System. Web. UI. Page
- {
- Private static int count = 1;
- Protected void Page_Load (object sender, EventArgs e)
- {
- Count;
- Response. Write ("var pv = document. getElementById (pv); pv. innerText =" count ";");
- }
- }
- Static Page staticHtml.html
- <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "
- <Html xmlns = "
- <Head>
- <Title> several methods for collecting dynamic page access volume </title>
- </Head>
- <Body>
- This is to use images for display.
- </Body>
- </Html>
- Accumulate page Imageact. aspx
- <% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Imageact. aspx. cs" Inherits = "ImageAddNumber" %>
- Imageact. aspx. cs code
- Public partial class ImageAddNumber: System. Web. UI. Page
- {
- Private static int count = 1;
- Protected void Page_Load (object sender, EventArgs e)
- {
- Count;
- String pv = count. ToString ();
- System. Drawing. Bitmap image = new System. Drawing. Bitmap (int) Math. Ceiling (pv. Length * 12.5), 22 );
- Graphics g = Graphics. FromImage (image );
- // Background color
- G. Clear (Color. White );
- Font font = new System. Drawing. Font ("Arial", 12, (System. Drawing. FontStyle. Bold | System. Drawing. FontStyle. Italic ));
- System. drawing. drawing2D. linearGradientBrush brush = new System. drawing. drawing2D. linearGradientBrush (new Rectangle (0, 0, image. width, image. height), Color. white, Color. red, (float) 1.2f, true );
- G. DrawString (pv, font, brush, 0, 0 );
- G. DrawRectangle (new Pen (Color. Gold), 0, 0, image. Width-1, image. Height-1 );
- System. IO. MemoryStream MS = new System. IO. MemoryStream ();
- Image. Save (MS, System. Drawing. Imaging. ImageFormat. Gif );
- Response. ClearContent ();
- Response. ContentType = "image/Gif ";
- Response. BinaryWrite (ms. ToArray ());
- }
- }