Following code works well for the session. however i need to find out how to track the number of visitors using web.conf. can anyone help?
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server" >
void Page_Load(object sender, System.EventArgs e)
{
int count = 0;
if (!(Page.IsPostBack)){
count = SessionHitCounter();
}
SessionCount.Text = Convert.ToString(count);
}
public int SessionHitCounter()
{
if (Session["HitCounter"] == null) {
Session["HitCounter"] = 1;
}
else {
Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
}
return ((int) Session["HitCounter"]);
}
void EnterBtn_Click(Object Src, EventArgs E)
{
// Populate the text box with the results from the call to the XML Web service method.
int i = SessionHitCounter();
SessionCount.Text = Convert.ToString(i);
}
</script>
<HTML>
<HEAD>
<TITLE>counter test</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<form runat="server" id="Form1">
<asp:button text="Bump Up Counter" Onclick="EnterBtn_Click" runat=server ID="Button1" NAME="Button1"/>
<p>
hit counter:
<ASP:LABEL ID="SessionCount" runat="server"></ASP:LABEL>
</form>
</BODY>
</HTML>
|