-2

好吧,我想这个问题不言自明。这是一些代码(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>");
            }
        }

我希望你们能帮助我。提前致谢。

4

1 回答 1

1

您可以使用 astatic 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;
}
于 2013-10-16T09:36:25.973 回答