手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >ASP.NET中在一般处理程序中使用session的简单介绍
ASP.NET中在一般处理程序中使用session的简单介绍
摘要:复制代码代码如下:usingSystem;usingSystem.Web;usingSystem.Web.SessionState;publ...

复制代码 代码如下:

<%@ WebHandler Language="C#" %>

using System;

using System.Web;

using System.Web.SessionState;

public class ChangePwd : IHttpHandler, IReadOnlySessionState

{

public void ProcessRequest (HttpContext context)

{

context.Response.ContentType = "text/plain";

OperUser ou = new OperUser();

if (ou.ChangeWsPassword(context.Session["ws_user"].ToString(),context.Request.QueryString["pwd"].ToString()))

{

context.Response.Write("true");

}

else

{

context.Response.Write("flase");

}

}

public bool IsReusable {

get {

return false;

}

}

}

加上 using System.Web.SessionState;和 IReadOnlySessionState

如果您的处理程序将访问会话状态值,它必须实现 IRequiresSessionState 接口(不包含任何方法的标记接口)。

导入using System.Web.SessionState;

果然,只要对自定义类加上一个IRequiresSessionState标记接口就可以了,也不需要实现任何的方法。

与此,同时还有另一个接口:IReadOnlySessionState接口,用于指示Http处理程序,对Session有只读的权限,也是空接口,无需实现任何方法。

【ASP.NET中在一般处理程序中使用session的简单介绍】相关文章:

ASP.NET MVC中将控制器分离到类库的实现

ASP.NET中application对象的使用介绍

ASP.NET程序中用Repeater实现分页

ashx中使用session的方法

ASP.NET 运行时错误: 没有为扩展名“.asax”注册的生成提供程序修正版

ASP.NET程序中常用代码汇总

ASP.NET实现的简单易用文件上传类

ASP.NET中的Cache使用介绍

在ASP.NET MVC 4 on Mono中使用OracleClient in CentOS 6.x的问题记录

ASP.NET中常用的优化性能的方法

精品推荐
分类导航