Below is the program which will show you how to maintain user page visit counts for web page. After each manual page refresh the count goes on increasing. Here us the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace show_user_visit_count_demo
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int x = 0;
try
{
if(Session["cnt"]==null)
{
x = 0;
}
else
{
x = Int32.Parse(Session["cnt"].ToString());
}
x++;
Session.Add("cnt", x.ToString());
Response.Write(x.ToString());
}
catch (Exception ex)
{
Response.Redirect("Error"+ex);
}
}
}
}
Comments
Post a Comment