关于在App_Code文件夹自定义类中Session无法使用

   由于前台页面需要调用App_Code中自定义类的函数,但在自定义类中找不到Session,解决方法如下:

 新建一个类session,并自己定义函数GetSession(),引用命名空间 System.Web

  

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 
 6 public static class session
 7 {
 8     public static object GetSession(string SessionName)
 9     {
10         return HttpContext.Current.Session[SessionName];
11     }
12 }

 

posted @ 2014-11-16 20:35  yyx3254  阅读(674)  评论(0编辑  收藏  举报