public int Increment() { var counterString = session.GetString("counter"); var counter = string.IsNullOrEmpty(counterString) ? 0 : int.Parse(counterString); counter++; session.SetString("counter", counter.ToString()); return(counter); }