码迷,mamicode.com
首页 > 其他好文 > 详细

一般应用程序中创建Session

时间:2015-04-03 13:03:11      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

  默认情况下,一般应用程序类继承了IHttpHandler接口,以允许对Http请求进行编程。IHttpHandler接口定义了一个方法:ProcessRequest(HttpContext context)和一个属性IsReusable。

  context.Session会话状态为只读,如果要对其进行操作,还要实现System.Web.SessionState命名空间下的IRequiresSessionState接口。IRequiresSessionState接口是一个标记接口,没有任何方法,它使指定目标HTTP 处理程序对会话状态值具有读写访问权。

 

技术分享
using System;
using System.Web;
using System.Web.SessionState;

public class Test : IHttpHandler,IRequiresSessionState
{
    
    public void ProcessRequest (HttpContext context) 
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");

        context.Session["UserID"] = 1;
    }
 
    public bool IsReusable 
    {
        get 
        {
            return false;
        }
    }

}

原文:http://www.cnblogs.com/morsh/archive/2009/11/04/1596140.html

一般应用程序中创建Session

标签:

原文地址:http://www.cnblogs.com/ihibin/p/4389490.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!