ashx文件中使用session提示“未将对象引用设置到对象的实例”
2014-05-15 10:41
676 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.SessionState;
namespace friends {
/// <summary>
/// Handler 的摘要说明
/// </summary>
public class Handler : IHttpHandler, IRequiresSessionState {
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/plain";
在使用一般处理程序时,会用session,但是在ashx文件中,默认时,无法向session创建新的键值,写了就会报错,就会提示:“未将对象引用设置到对象的实例”
那么,将此ashx文件类继承一个接口,如以下所示:
System.Web.SessionState.IReadOnlySessionState 为只读会话的接口 继承这个接口,只能读取session 但不能为session赋值
System.Web.SessionState.IRequiresSessionState 为可读可写的 继承这个接口,即可读取session的值,也可以对其赋值,所以在一般处理程序中,继承这个接口
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.SessionState;
namespace friends {
/// <summary>
/// Handler 的摘要说明
/// </summary>
public class Handler : IHttpHandler, IRequiresSessionState {
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/plain";
在使用一般处理程序时,会用session,但是在ashx文件中,默认时,无法向session创建新的键值,写了就会报错,就会提示:“未将对象引用设置到对象的实例”
那么,将此ashx文件类继承一个接口,如以下所示:
System.Web.SessionState.IReadOnlySessionState 为只读会话的接口 继承这个接口,只能读取session 但不能为session赋值
System.Web.SessionState.IRequiresSessionState 为可读可写的 继承这个接口,即可读取session的值,也可以对其赋值,所以在一般处理程序中,继承这个接口
相关文章推荐
- ashx文件中使用session提示“未将对象引用设置到对象的实例”
- ashx文件中使用session提示“未将对象引用设置到对象的实例”的解决方法
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例上[转]
- ashx文件中使用session提示“未将对象引用设置到对象的实例”
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例上
- ASP.NET在.ashx文件中使用session出异常,未将对象引用到对象的实例
- ASP.NET在.ashx文件中使用session出异常,未将对象引用到对象的实例。
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例
- ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例
- 如何在ashx页面获取Session值(未将对象引用设置到对象的实例)
- ashx和session解决未将对象引用设置到对象的实例问题
- ASHX中引用Session 出现“呈现未将对象引用设置到实例上”
- ashx中应用HttpContext.Current.Session ,呈现未将对象引用设置到实例(转)
- ashx页面中 Session值出现“未将对象引用设置到对象的实例”错误
- 牛腩 45 整合类别管理(1) session未将对象引用设置到对象的实例,repeater控件的使用,linkbutton的删除
- ashx页面中 Session值出现“未将对象引用设置到对象的实例”错误
- 如何在ashx页面获取Session值(未将对象引用设置到对象的实例) (转)
- ashx页面中 Session值出现“未将对象引用设置到对象的实例”错误