Toplam Ziyaretçi Sayısı & Online Ziyaretçi Sayısı — Asp net — C#

Toplam Ziyaretçi Sayısı & Online Ziyaretçi Sayısı — Asp net — C#

Default.aspx

[code lang=”html”]

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 152px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<table class="auto-style1">
<tr>
<td class="auto-style2">Toplam Ziyaretci :</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">Online Ziyaretci :</td>
<td>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>

</div>
</form>
</body>
</html>

[/code]

 

Default.aspx.cs

[code lang=”csharp”]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;//www.gorselprogramlama.com
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Application["ToplamZiyaretci"].ToString();
Label2.Text=Application["OnlineZiyaretci"].ToString();

}
}//www.gorselprogramlama.com
</a>

[/code]

 

Global.asax

[code lang=”csharp”]

<%@ Application Language="C#" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{
//www.gorselprogramlama.com
Application.Add("ToplamZiyaretci",0);
Application["OnlineZiyaretci"]=0;

}

void Application_End(object sender, EventArgs e)
{

Application["OnlineZiyaretci"] = Convert.ToInt32(Application["OnlineZiyaretci"]) – 1;

}

void Application_Error(object sender, EventArgs e)
{

}

void Session_Start(object sender, EventArgs e)
{
//www.gorselprogramlama.com
Application["ToplamZiyaretci"] = Convert.ToInt32(Application["ToplamZiyaretci"]) + 1;
Application["OnlineZiyaretci"] = Convert.ToInt32(Application["OnlineZiyaretci"]) + 1;

}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
Application["OnlineZiyaretci"] = Convert.ToInt32(Application["OnlineZiyaretci"]) – 1;

}

</script>

[/code]

 

toplam_online_ziyaretci

 

Projeyi İNDİR

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir