我做的网站采用三层架构 
数据层  逻辑层   表现层
我在逻辑层定义了一个类AboutCheck.cs
我写了如下判断代码  
public class AboutCheck
{
public AboutCheck(string SubjectA)
{
if (HttpContext.Current.Session["admincheck"]!=null)
{
HttpContext.Current.Response.Redirect("../logine.aspx");
}
} }
逻辑层添加system.web的引用 AboutCheck里面添加如下引用:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
编译后,浏览调用该类的页面,提示说未将对象引用到实例,测试后发现,逻辑层中并没有继承页面中的session 
请问应该怎样在AboutCheck.cs中引用SessionSystem.Web.HttpContext.Current.Session["~~~~"];  也不能引用   :~(80分相送   问题解决立刻揭帖 在线等

解决方案 »

  1.   

    不可使用session。
    逻辑层中的方法是等待你的web调用的,你需要将值传递给逻辑层中的方法,让其作业务逻辑处理。
    你怎么能将session传到逻辑层呢,你要传的是session中保存的值
      

  2.   

    你的做法是没问题的,
    System.Web .HttpContext .Current .Session
    看你在哪里调用,只要你不在多线程中调用,不应会出现此错误,
      

  3.   

    AboutCheck aboutCheck = new AboutCheck(SubjectA)还有你的问题有岐义,看得不是很明白
      

  4.   

    只可以将session 传递到逻辑层,不可直接引用.
      

  5.   

    当然你的设计可能不好.
    应这样在 逻辑层 
    public bool AboutCheck(object check)
    {
    public AboutCheck(string SubjectA)
    {
    if (chekc!=null) return true;
    else return false;
    } }在表现层
    if (new AboutCheck().AboutCheck((Session["admincheck"]))
    Redirect("../login.aspx");