//在VS2008中循环显示Session:

         方法1:

        Response.Write("<br>Session的所有值:<br>");
        foreach (string key in Session.Contents)
        {
            Response.Write(key.ToString() + ":  " + Session[key].ToString() + "<br>");

        }

        方法2:

        for (int i = 0; i < Session.Contents.Count; i++)
        {

            Response.Write(Session.Keys[i].ToString() + ":  "+ Session[i].ToString() + "<br>");
        }


        //在VS2008中循环显示Cookies:
        Response.Write("<br>Cookies的所有值:<br>");
        for (int i = 0; i < HttpContext.Current.Request.Cookies.Count; i++)
        {
            Response.Write(HttpContext.Current.Request.Cookies.Keys[i] + ":  " + HttpContext.Current.Request.Cookies[i].Value.ToString() + "<br>");
        }


        //在VS2008中循环显示Application:
        Response.Write("<br>Application的所有值:<br>");
        for (int i = 0; i < HttpContext.Current.Application.Count; i++)
        {
            Response.Write(HttpContext.Current.Application.Keys[i] + ":  " + HttpContext.Current.Application[i].ToString() + "<br>");
        }

相关文章:

  • 2022-02-21
  • 2022-12-23
  • 2021-11-03
  • 2021-05-16
  • 2021-05-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案