未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
行 36:         //if (Request.Cookies["JiHuoAx"] != null)
行 37:         //{
行 38:             Response.Write(Request.Cookies["JiHuoAx"].Value);
行 39: 
行 40:         //}
 
源文件: e:\网站\用户验证网站\UserInfo.aspx.cs    行: 38 
JS写Cookievar Then = new Date();
Then.setTime(Then.getTime() +3600*1000*24*300 );
document.cookie = "JiHuoAx=Axtrue;expires="+ Then.toGMTString();
Net读取        if (Request.Cookies["JiHuoAx"] != null)
        {
            Response.Write(Request.Cookies["JiHuoAx"].Value);        } 这里Cookies["JiHuoAx"]一直都为Cookie,但我用JS就可以读取出来Axtrue不知道是那个出的错误!

解决方案 »

  1.   

    我在Documents and Settings里面的用户文件夹内COOKIE文件夹内有我生成的Cookie文件~
      

  2.   


     <script type="text/javascript">
        function setCookie()
        {
            
            document.cookie=null;
            document.cookie="name=aaa;";
            alert("保存成功");
        }
        </script>
     <form id="form1" runat="server">
        <div>
        <input type="button" value="写Cookie" onclick="setCookie()" />
            <asp:Button ID="Button1" runat="server" Text="读取" OnClick="Button1_Click" />
        </div>
        </form> if (Request.Cookies["name"] != null)
            {
                Response.Write(Request.Cookies["name"].Value);
            }
    可以读取到