if(!Page.IsPostBack)
{
string us;
us=Convert.ToString(Session["userclass"]);
if(us.Trim()=="系统管理员"||(int)Session["addnews"]==1||(int)Session["addnchk"]==1)
{getClass();}
else
{Page.Visible=false;}
}
未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。行 264: string us;
行 265: us=Convert.ToString(Session["userclass"]);
行 266: if(us.Trim()=="系统管理员"||(int)Session["addnews"]==1||(int)Session["addnchk"]==1)
行 267: {getClass();}
行 268: else
 
源文件: c:\inetpub\wwwroot\webnews\admin\admin_articleadd.aspx.cs    行: 266 

解决方案 »

  1.   

    if(Session["userclass"] != null)
    {
    us=Convert.ToString(Session["userclass"]);..
    }
      

  2.   

    if(Session["userclass"] != null)
    {
    string us;
    us=Convert.ToString(Session["userclass"]);
    if(us.Trim()=="系统管理员"||(int)Session["addnews"]==1||(int)Session["addnchk"]==1)
    {getClass();}
    else
    {Page.Visible=false;}
    }
      

  3.   

    if(!Page.IsPostBack)  
                                       {  
                                                   string  us;  
                                                   us=Convert.ToString(Session[  "userclass  "]);  
                                                   if(Session[  "userclass  "]  !=  null)  
                                                   {getClass();}  
                                                   else  
                                                   {Page.Visible=false;}  
                                       }  
    在浏览器中出现的页面什么也没有是空白。