最新国产好看的视频,伊人天堂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程序設計有所幫助

相關文章

最新評論

宣汉县| 揭西县| 马公市| 富川| 莲花县| 通州区| 盐津县| 安新县| 青田县| 上蔡县| 纳雍县| 比如县| 孟连| 吴桥县| 古交市| 博客| 虹口区| 饶河县| 二连浩特市| 贺兰县| 石林| 大关县| 新余市| 余干县| 宁德市| 永和县| 合山市| 仙居县| 仲巴县| 砚山县| 溧水县| 泸溪县| 忻州市| 临夏市| 营口市| 嘉黎县| 阳原县| 南召县| 贡嘎县| 翁牛特旗| 南丹县|