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

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:28:07
字體:
供稿:網(wǎng)友
這篇文章主要介紹了*.ashx文件不能訪問Session值的解決方法,只需在頭部引用一個命名空間即可解決問題,非常實(shí)用,需要的朋友可以參考下
 
 

本文實(shí)例講述了*.ashx文件不能訪問Session值的解決方法。分享給大家供大家參考之用。具體方法如下:

實(shí)例代碼如下:

<%@ 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;     }   } }

其實(shí)只要加上這句就好了:

using System.Web.SessionState;

希望本文所述對大家的asp.net程序設(shè)計(jì)有所幫助


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 麻阳| 永德县| 菏泽市| 娄烦县| 安宁市| 城固县| 凤台县| 通山县| 扎囊县| 黎平县| 龙陵县| 黎平县| 霍林郭勒市| 偃师市| 大余县| 历史| 咸丰县| 通州区| 资溪县| 中超| 徐州市| 常德市| 游戏| 陇西县| 榆林市| 浦县| 兰州市| 河西区| 沙田区| 贡嘎县| 聊城市| 濮阳市| 安溪县| 抚宁县| 绥宁县| 隆昌县| 阿坝| 廊坊市| 综艺| 肥城市| 武冈市|