ASP.NET中在一般处理程序中使用session的简单介绍
2014-02-14 09:20
375 查看
这篇文章介绍了ASP.NET中在一般处理程序中使用session,有需要的朋友可以参考一下
复制代码 代码如下:
<%@ WebHandler Language="C#" Class="ChangePwd" %>
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有只读的权限,也是空接口,无需实现任何方法。
详细出处参考:/article/1273694.html
复制代码 代码如下:
<%@ WebHandler Language="C#" Class="ChangePwd" %>
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有只读的权限,也是空接口,无需实现任何方法。
详细出处参考:/article/1273694.html
相关文章推荐
- ASP.NET中在一般处理程序中使用session的简单介绍
- ASP.NET中在一般处理程序中使用session的简单介绍
- ASP.NET中在一般处理程序中使用session的简单介绍
- ASP.NET一般处理程序(.ashx.cs)中使用Session的问题
- asp.net .ashx一般处理程序中使用Session
- asp.net 中一般应用处理程序使用session
- ASP.NET中在一般处理程序中如何使用session
- asp.net- ajax简单入门使用方法,通过一般处理程序ashx进行处理
- asp.net一般处理程序中使用session
- asp.net中在一般处理程序中使用session
- ASP.NET:在一般处理程序中通过 Session 保存验证码却无法显示图片?
- ASP.NET一般处理程序新建一个方法里使用context.Response.Write的解决方法
- ASP.NET的ASHX一般处理程序中Session为null且不能赋值
- ASP.Net一般处理程序Session用法,以及cookie的用法
- asp.net 使用一般处理程序和ajax post实现登录以及记住密码
- 使用HTML页面和一般处理程序模拟ASP.NET WebForms中的事件
- ASP.NET一般处理程序访问Session问题
- ASP.NET 使用一般处理程序.ashx进行 Excel下载
- asp.net中一般处理程序中添加session
- Asp.net 一般处理程序.ashx中对Session的操作