*.ashx文件不能访问Session值的解决方法
2014-09-05 00:00
585 查看
本文实例讲述了*.ashx文件不能访问Session值的解决方法。分享给大家供大家参考之用。具体方法如下:
实例代码如下:
其实只要加上这句就好了:
希望本文所述对大家的asp.net程序设计有所帮助
实例代码如下:
<%@ WebHandler Language="C#" Class="productHandler" %> using System; using System.Web; using JBTCard.Entity.CompanyEntity; using JBTCard.Business.CompanyBS; using System.Collections.Generic; using Newtonsoft.Json; using System.Web.SessionState; public class productHandler : IHttpHandler, IRequiresSessionState, IReadOnlySessionState{ public void ProcessRequest (HttpContext context) { string moduleId = context.Request.Form["moduleId"].ToString(); string message = ""; switch (moduleId) { case "getPTypeList": IList<ProductTypeIdNameEntity> list = ProductTypeBS.GetPTypeListIdName(); message = JavaScriptConvert.SerializeObject(list); break; case "getCompanyById": int cid = Convert.ToInt32(context.Session["cid"]); CompanyEntity company = CompanyBS.GetCompanyEntyById(1); message = JavaScriptConvert.SerializeObject(company); break; case "insert": string condis = context.Request.Form["condi"].ToString(); ProductEntity model = (ProductEntity)JavaScriptConvert.DeserializeObject(condis, typeof(ProductEntity)); bool b = ProductBS.AddProduct(model); if (b) { message = "{success:true}"; } else { throw new Exception("商品添加失败!"); } break; } context.Response.ContentType = "text/javascript"; context.Response.Write(message); } public bool IsReusable { get { return false; } } }
其实只要加上这句就好了:
using System.Web.SessionState;
希望本文所述对大家的asp.net程序设计有所帮助
相关文章推荐
- *.ashx文件不能访问Session值的解决方法
- *.ashx一般处理程序不能访问Session值的解决方法
- Windows Server 2008下Microsoft Office Excel 不能访问文件解决方法
- XP不能访问Win7系统下共享文件的解决方法
- Microsoft Excel不能访问文件,不能保存,不能单击打开文件的解决方法
- 本地和服务器导出Excel报“Microsoft Office Excel 不能访问文件” 解决方法
- 关于文件不能访问,IIS提示MIME类型没有错误的解决方法
- [导入]解决打开CHM格式文件出现“网页不能浏览”错误的方法
- 关于Sql Server企业管理器MMC 不能打开文件的解决方法
- 关于Sql Server企业管理器MMC 不能打开文件的解决方法
- 2003上传文件不能超过200k问题解决方法问题
- 解决打开CHM格式文件出现“网页不能浏览”错误的方法
- Ubuntu下不能重命名文件的解决方法
- 解决Enterprise Library - January 2006不能加密配置文件的方法(转)
- 上传文件不能超过200KB解决方法(win2003)
- 能访问html不能访问asp的解决方法
- 不能删除MP4里的音视频文件的解决方法
- 关于.net对文件的访问被拒绝的一点解决方法
- 两台winXP电脑不能互相访问共享文件夹故障的最终解决方法
- [导入]解决打开CHM格式文件出现“网页不能浏览”错误的方法