国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

*.ashx文件不能訪問Session值的解決方法

2024-07-10 12:48:30
字體:
來源:轉載
供稿:網友

本文實例講述了*.ashx文件不能訪問Session值的解決方法。之用。具體方法如下:

實例代碼如下:

<%@ 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程序設計有所幫助

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 夹江县| 罗甸县| 仁寿县| 昭通市| 天气| 疏附县| 普定县| 高邮市| 武威市| 土默特右旗| 宁乡县| 黔东| 喀喇沁旗| 漳州市| 威信县| 邻水| 石景山区| 宁国市| 佛教| 陇川县| SHOW| 霍山县| 鹰潭市| 定陶县| 绍兴县| 平潭县| 涪陵区| 镇远县| 武汉市| 桂东县| 东明县| 淮安市| 固阳县| 阿合奇县| 磐石市| 深泽县| 武汉市| 海南省| 察隅县| 个旧市| 平武县|