Object reference not set to an instance of an object 为什么只有一台电脑一直出现这个错识?其它电脑全部没有问题?
代码如下:
{
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
                         
                 powers();
                names();
            }
        
    }
    /// <summary>
    /// 返回权限值
    /// </summary>
    /// <returns></returns>
    protected string powers()
    {
        
        power = cookeis.Values["power"];
         
        return power;
       
        
    }
    /// <summary>
    /// 返回工号BM
    /// </summary>
    /// <returns></returns>
    protected string names()
    {
     
         
        name = cookeis.Values["uName"];
        return name;
    }
   
 }
我也按照这个贴子:http://topic.csdn.net/u/20080305/10/4d3080a6-0000-45a8-a1ed-bb037447543f.html
试了,一下,也不行啊?郁闷死了,我现在怀凝是不是那台电脑硬盘有问题,存不住COOKie啊??

解决方案 »

  1.   

    首先,在使用引用类型应判断是否为null其次,客户端可能禁用了cookie
      

  2.   

    cookie 为空 ?? ie 禁用了cookie??
      

  3.   

    cookeis.Values["power"];
    为null
    客户端浏览器中禁止 Cookie
      

  4.   

    不同的浏览器设置cookie 是不一样的http://iask.sina.com.cn/b/11074726.html
      

  5.   

    改用session
    在web.config 
    sessionstate 节把cookieless设为trueps:好久没写程序可能有小问题
      

  6.   

    我都接受了所有的COOKie,还是不行
      

  7.   

    Object reference not set to an instance of an object. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
      

  8.   

       /// <summary>
        /// 返回权限值
        /// </summary>
        /// <returns></returns>
        protected string powers()
        {
            
            power = cookeis.Values["power"];
              建议
            if(power ==null)return "NULL";
            return power;
           
            
        }
        /// <summary>
        /// 返回工号BM
        /// </summary>
        /// <returns></returns>
        protected string names()
        {
         
             
            name = cookeis.Values["uName"];
             建议
            if(name==null)return "NULL";
            return name;
        }
       
    这两个return 可能为null 对后续有可能对null对象进行操作 问题不在你贴 的代码里 在你对后续返回的操作
    cookie别禁用
      

  9.   

    name = cookeis.Values["uName"];cookeis 实例化了吗