嗯,我想这个问题不言而喻。这里有一些代码(test.cs)使它更清晰:
while (reader.Read())
{
string sessieVak = reader["vak"].ToString();
if (variable == "cool")
{
//This part can only happen once in the entire application
HttpContext.Current.Session[sessieVak] = true;
}
if (HttpContext.Current.Session[sessieVak] != null)
{
str.Append("<li><a href = vak.aspx?id=" + reader["kdv_ID"] + " />" + reader["vak"] + "</a></li>");
}
}
我希望你们能帮助我。 提前谢谢。
答案 0 :(得分:1)
您可以使用static bool
作为标志:
static bool done = false;
if (variable == "cool" && done == false)
{
//This part can only happen once in the entire application
HttpContext.Current.Session[sessieVak] = true;
done = true;
}