Here's a quick fix for that.
First, create a class that will handle your SessionCounter;
public class SessionCounter {
public SessionCounter() {
Counter = 1;
LastPage = "A";
}
public int Counter { get; set; }
public string LastPage { get; set; }
}
Then on your webpage insert this on your Page_Load
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
SessionCounter sc = new SessionCounter();
if (Session["SessionCounter"] != null) {
sc = (SessionCounter)Session["SessionCounter"];
if (sc.LastPage == "C") {
sc.Counter++;
}
sc.LastPage = "A";
}
Session["SessionCounter"] = sc;
}
}
Good luck!