没有直接的方法,不过可以在页面的Page_Load事件中加入一个记录SessionID的方法,退出页面时删除。这样可以实现的。

解决方案 »

  1.   

    在每次页面加载的时候记录sessionid的值,同意楼上的做法
      

  2.   

    在每次页面加载的时候记录sessionid的值,然后再其他页面中的load事件中要有sessionid的删除方法。因为当客户端读取其他页面时是无法在你所要的那个页面做删除sessionid的工作的。
      

  3.   

    using System;
    using System.Collections;
    using System.Web;
    using System.Web.SessionState;namespace WebApplication1
    {
    /// <summary>
    /// TestHttpHandler 的摘要说明。
    /// </summary>
    public class TestHttpHandler:IHttpHandler,IRequiresSessionState
    {
    public TestHttpHandler()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    }
    #region IHttpHandler 成员 public void ProcessRequest(HttpContext context)
    {
    Hashtable hash;
    int UserNumber=0;
    if(context.Cache["UserList"]!=null)
    {
    hash=(Hashtable)context.Cache["UserList"];
    }
    else
    {
    hash=new Hashtable();
    }
    if(context.Cache["UserNumber"]!=null)
    {
    UserNumber=Convert.ToInt32(context.Cache["UserNumber"]);
    }

    if(!hash.Contains(context.Session.SessionID))
    {
    hash.Add(context.Session.SessionID,"游客");
    UserNumber+=1;
    context.Cache["UserList"]=hash;
    context.Cache["UserNumber"]=UserNumber;
    } IDictionaryEnumerator id=hash.GetEnumerator();
    while(id.MoveNext())
    {
    context.Response.Write(id.Value.ToString().Trim());
    }
    } public bool IsReusable
    {
    get
    {
    // TODO:  添加 TestHttpHandler.IsReusable getter 实现
    return true;
    }
    } #endregion
    }
    }webConfig文件修改
     <system.web>
    <httpHandlers>
             <add verb="*" path="WebForm1.aspx" type="WebApplication1.TestHttpHandler,WebApplication1"/>
          </httpHandlers>
     </system.web>参见:ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemwebihttphandlerclassprocessrequesttopic.htm这个需要注意以下,你要把这个路径WebForm1.aspx设置为IFrame的路径并将IFrame放入你需要确认登陆的网页
    至于判断用户登出,除了在页面上放置登出按钮外,就需要在golbal中的SessionEnd方法中判断并删除超时的Session了