<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["online"] = 0;
}
void Session_Start(object sender, EventArgs e)
{
Application["online"] = int.Parse(Application["online"].ToString()) + 1;
Session.Timeout = 5;
}
void Session_End(object sender, EventArgs e)
{
Application["online"] = int.Parse(Application["online"].ToString()) - 1;
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
int son_sayfa_adet = 40;
if (Request.RawUrl.Contains(".aspx"))
{
StreamReader sr = new StreamReader(Server.MapPath("~/online.txt"), System.Text.Encoding.Default);
string sonuc = sr.ReadToEnd();
sr.Close();
string[] dizi = sonuc.Split('\r');
if (dizi.Length <= son_sayfa_adet)
{
StreamWriter sw = new StreamWriter(Server.MapPath("~/online.txt"), true, System.Text.Encoding.Default);
sw.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " " + Request.RawUrl);
sw.Close();
}
else
{
StreamWriter sww = new StreamWriter(Server.MapPath("~/online.txt"));
sww.WriteLine("");
sww.Close();
StreamWriter sw = new StreamWriter(Server.MapPath("~/online.txt"));
for (int i = 1; i <= son_sayfa_adet - 1; i++)
{
sw.WriteLine(dizi[i].Replace("\n", ""));
}
sw.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " " + Request.RawUrl);
sw.Close();
}
}
}
</script>