最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2014年09月05日 11:37:10   投稿:shichen2014  
這篇文章主要介紹了*.ashx文件不能訪問Session值的解決方法,只需在頭部引用一個命名空間即可解決問題,非常實用,需要的朋友可以參考下

本文實例講述了*.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程序設(shè)計有所幫助

相關(guān)文章

最新評論

鹤峰县| 凤城市| 政和县| 贵德县| 万载县| 田林县| 赣州市| 唐山市| 黑龙江省| 水城县| 安泽县| 唐山市| 高台县| 万源市| 铜陵市| 柞水县| 靖宇县| 扎囊县| 宿州市| 金川县| 香河县| 蒙阴县| 阜南县| 桃江县| 平凉市| 文水县| 利辛县| 从化市| 阿勒泰市| 大理市| 裕民县| 沂南县| 化州市| 阿鲁科尔沁旗| 开阳县| 黄平县| 于田县| 分宜县| 成武县| 阿勒泰市| 高碑店市|