You need to use Global.asax file.use Application_Start
void Application_Start(object sender, EventArgs e)
{
// write code to insert into Database
}
also need to check if user visit count has exceeds 20 count inside Application_BeginRequest
void Application_BeginRequest(object sender, EventArgs e)
{
//get user vist count here
// check if count is greter than 20 then simply log out the user
}
I hope this will help you out.