I have a counter on my site, which I handle myself. I put a code for incrementing a counter by 1 in my Session_Start method of Global.asax.cs file:
protected void Session_Start(Object sender, EventArgs e)
SqlConnection conn = null;
string connStr = ConfigurationSettings.AppSettings[ "ConnStr" ];
conn = new SqlConnection( connStr );
string sql = "UPDATE counter_table SET counter = counter + 1 WHERE id = 1";
SqlCommand cmd = new SqlCommand( sql, conn );
if( conn != null )
It works absolutelly fine on my local server, but when I upload it to the web-server (of my web-hosting company), it behaves a bit strange.
It does increase the counter when someone comes first to the web-site. Then, if this someone goes to another page and returnes to the main page, the counter gets incremented again... but only once - if this repeated (go to a different page and come back on the main one), the counter stays the same.
I got nothing incrementing in my page load - my Global.asax is empty beside the code you saw above + InitializeComponents in the constructor... Any idea what can cause it?