奇怪的问题,在本地项目运行不会报错~~~怎么调试怎么注销都没问题,可在服务器上就会报“未将对象引用设置到对象的实例”这个错,服务器上我一点击注销就报错了~~注销的内容就的清除cookies和session的值……本机调试不出问题所在~~服务器上面偶尔会报错偶尔不会,我就更郁闷了!!以下是错误提示,请问是什么问题呢,很急~~~~~
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
[NullReferenceException: 未将对象引用设置到对象的实例。]
   Login.Page_Load(Object sender, EventArgs e) +718
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

解决方案 »

  1.   

    是不是你那台服务器的浏览器禁止了Cookie,就是说不保存Cookie,虽然你程序中保存了,但是在你点击注销的时候,该Cookie对象已经不存在了,所以报“未将对象引用设置到对象实例”这个错误。
      

  2.   

    有null值 肯定要报空异常。
      

  3.   


    服务器上没有禁止Cookie,我的注销是这样的~
    HttpCookie cookies = HttpContext.Current.Request.Cookies["ticket"];
    cookies.Value = "";
    cookies.Domain = Utils.GetAppSettingsValue("domain");
    cookies.Expires = DateTime.Today.AddDays(-1000);
    HttpContext.Current.Response.Cookies.Add(cookies);
    HttpContext.Current.Session["UserID"] = "";
    HttpContext.Current.Session.Abandon();
    Utils.SetCookies("user", "", cookies.Domain, DateTime.Now.AddSeconds(-1));Utils.SetCookies是一个设置Cookies的方法
    public static void SetCookies(string cName, string cValue, string domain, Nullable<DateTime> cExpires)
    {
    HttpCookie cookies = new HttpCookie(cName);
    if (!string.IsNullOrEmpty(domain))
    {
    cookies.Domain = domain;
    }
    if (cExpires is DateTime)
    {
    cookies.Expires = (DateTime)cExpires;
    }
    cookies.Value = cValue;
    HttpContext.Current.Response.Cookies.Add(cookies);
    }这样的注销,我本地完全正常~~~~~哪里有问题不??
      

  4.   


    不是的~~注销成功后是回跳到注销前的页面的~~~就这样子, Response.Redirect(Request.UrlReferrer);是这样子的~~然后我今天访问网站,点注销又没问题了~~不会出错了,这个问题很不稳定,是否和服务器上的设置有关系呢?还是程序问题?
      

  5.   

    cookies 是 NULL吧  打印出来看一看