You can simplfy the setting of your count variable by using it as a property, which I believe will also solve your problem.
public static int Count
{
get
{
return Application["myCount"] != null
? Convert.ToInt32(Application["myCount"]
: 0;
}
set { Application["myCount"] = value; }
}
Then simply use the short hand operators for incrementing and decrementing the counter:
public void Session_Start(Object sender, EventArgs e)
{
Count++;
}
public void Session_End(Object sender, EventArgs e)
{
if (Session["PNetUserName"]!=null)
{
Session.Abandon();
Session.Clear();
Count--;
}
}