asp.net开发网站或网站应用程序时当使用Session[...]时,接口,System.Web.SessionState.IRequiresSessionState不要忘记实现,但该接口没任何方法需要实现,只写上即可

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Web.Layer3.APP.Login
{
/// <summary>
/// LoginOut 的摘要说明
/// </summary>
public class LoginOut : IHttpHandler,System.Web.SessionState.IRequiresSessionState//******!!!!!!!!使用Session[...]时,这个接口不要忘记实现,但该接口没任何实现
{

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
if (context.Session["userInfo"]!=null)
{
context.Session["userInfo"] = null;
context.Response.Cookies["cp1"].Expires = DateTime.Now.AddDays(-1);
context.Response.Cookies["cp2"].Expires = DateTime.Now.AddDays(-1);
context.Response.Redirect("Login.aspx");
}
}

posted @ 2026-03-09 20:09  techNote  阅读(0)  评论(0)    收藏  举报