.ashx中引用 session必须 using System.Web.SessionState ,继承IReadOnlySessionState/IRequiresSessionState

IReadOnlySessionState,为只读的session 不可以修改

IRequiresSessionState ,可以修改。

using System;
using System.Web;
using System.Text;
using System.Web.SessionState; //这是在.ashx 中引用session 的必备条件之一

public class GetCheckData : IHttpHandler,IRequiresSessionState //继承IRequiresSessionState
 {

public void ProcessRequest(HttpContext context)
    {        
       context.Response.ContentType = "text/plain";

string ds="1234";

context.Session["ds"] = ds;//这只是简单的使用方法,可以根据自己的要求改

HttpContext.Current.Session["ds"]=ds;//第二种方法

context.Response.Write(ds);

}

}

C#使用一般处理程序(ashx)中session的更多相关文章

  1. ASP.NET MVC 项目中 一般处理程序ashx 获取Session

    1-在 aspx和aspx.cs中,都是以Session["xxx"]="aaa"和aaa=Session["xxx"].ToString( ...

  2. ashx中session的使用

    在平常的页面上是用是很容易就的到request,response对像,从而对其进行一些操作,但在ashx(一般处理程序)中却是有一点的不同, 在ashx你无法正常的使用session,即 contex ...

  3. [asp.net]ashx中session存入,aspx为null的原因(使用flash uploader)

    I am using uploadify to upload files, they automatically post to the handler. I then modify the sess ...

  4. 一般处理程序 ashx中使用外部Session 出现不存在 解决方案

    MXS&Vincene  ─╄OvЁ  &0000004 ─╄OvЁ  MXS&Vincene MXS&Vincene  ─╄OvЁ:今天很残酷,明天更残酷,后天很美好 ...

  5. 一般处理程序ashx中用session存储数据

    如果要使用session的话,在handler的代码中添加System.Web.SessionState的引用,并让这个handler继承IRequiresSessionState接口,一定要继承这个 ...

  6. await和async在C#一般处理程序(ashx)中的使用

    public class hello : HttpTaskAsyncHandler, IReadOnlySessionState { public IFetchServise fetch { get; ...

  7. ASP.NET ASHX中获得Session

    有时候需要在ASHX中获取Session,可是一般是获取不到的,如何解决? 1-在 aspx和aspx.cs中,都是以Session["xxx"]="aaa"和 ...

  8. 一般处理程序中用到session时

    一般处理程序ashx文件使用session 1.先引用System.Web.SessionState这个命名空间, 2.如果是要在HttpHandler中读取Session的内容,就要在实现IHttp ...

  9. jQuery获取一般处理程序(ashx)的JSON数据

    昨天有在开发的软件生产线生产流程,RFID扫描IC卡的数据,当中有用到jQuery获取一般处理程序(ashx)的JSON数据.今有把它写成一个小例子,望需要的网友能参考. 在网站中,创建一个一般应用程 ...

随机推荐

  1. objc_clear_deallocating 与弱引用

    void *objc_destructInstance(id obj){ if (obj) { Class isa_gen = _object_getClass(obj); class_t *isa ...

  2. CF817F MEX Queries(线段树上二分)

    题意 维护一个01串,一开始全部都是0 3种操作 1.把一个区间都变为1 2.把一个区间都变为0 3.把一个区间的所有数字翻转过来 每次操作完成之后询问区间最小的0的位置 l,r<=10^18 ...

  3. Object-C,四则运算计算器

    下面是是一个比较复杂的类. 定义一个四则运算计算器Caculator的接口和实现. 在main函数中,让用户输入四则运算表达式,比如a+b,a-b. 最后,在控制台输出结果. 用到的语法:接口.类的定 ...

  4. Linux学习总结(9)——Linux 新手必知必会的 10 条 Linux 基本命令

    Linux 对我们的生活产生了巨大的冲击.至少你的安卓手机使用的就是 Linux 核心.尽管如此,在第一次开始使用 Linux 时你还是会感到难以下手.因为在 Linux 中,通常需要使用终端命令来取 ...

  5. Spring Boot学习总结(1)——Spring Boot入门

    摘要:Spring Boots是为了帮助开发人员很容易的创建出独立运行和产品级别的基于 Spring 框架的应用. 从 Spring Boot 项目名称中的 Boot 可以看出来,Spring Boo ...

  6. [Poi] Build and Analyze Your JavaScript Bundles with Poi

    Ever wonder where those extra KB in your bundle are coming from? This lesson walks you through runni ...

  7. BestCoder 1st Anniversary ($) 1002.Hidden String

    Hidden String Accepts: 437 Submissions: 2174 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 26 ...

  8. c#时间差高精度检查

    两个时间差的高精度检查 static void Main(string[] args) { Console.WriteLine("开始时间:" + DateTime.Now.ToS ...

  9. Scrapy中将数据保存至数据库

    一.在settings.py文件中配置数据库连接参数 # 数据库连接参数 DB_HOST = '192.168.183.1' DB_PORT = 3306 DB_USER = 'root' DB_PA ...

  10. @Mapper注解在springboot中无法注入

    问题① @Mapper注解报红无法注入 方法 在pom文件中添加依赖