错误提示如下:Server Error in '/cy0506' Application.
--------------------------------------------------------------------------------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. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: 
[NullReferenceException: Object reference not set to an instance of an object.]
   UserWeb_Html_HomeHTML_MasterPage.Enter_Click(Object sender, EventArgs e) +67
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832 为什么纳闷呢?
第一:在vs内置浏览器中浏览没错(代码也绝对没问题,找了一上午了)。
第二:发布后在IIS上面浏览,也是没错的(经过多方面测试,证明了这一点)。
第三:当我把发布到IIS上面的Web发布到服务器的时候,居然给我报一个上面错误(而在我自己的机子上面又是正正常的、IIS用的别人的机子:自己机器上面的IIS不能用了要重装系统)。
以上三点遇到过的大虾请给我说一下,急~~~~~   
,QQ:804458949.
解决此问题我愿意加分。

解决方案 »

  1.   

    是不是以前都是用虚拟路径部署的,在后来用了web site部署啊?把Enter_Click()的内容贴出来看看
      

  2.   

     //创建username session
            Session["UserName"] = this.EnterName.Value;
            //读取验证码session
            string yanz = Session["checkcode"].ToString();
            string CheckCode = this.EnterYanz.Value;
            if (yanz == CheckCode && CheckCode != null)
            {
                Response.Redirect("../../../UserWeb/Html/Error/Tiaozhuan.aspx");
            }
            else
            {
                Response.Redirect("../../../UserWeb/Html/Error/Error.htm");
            }
      

  3.   

    string yanz = Session["checkcode"].ToString(); 
    估计是这句出问题了,Session["checkcode"]为NULL了
      

  4.   

    Session["checkcode"]会不会是空?
    看看是不是对应的67行
      

  5.   

    string yanz = Session["checkcode"] as string; 
    检测结果
      

  6.   

    Session数据“丢失”说了无数次了,甚至有人列举了许多可能性(虽然从来没有人能够真正做到不再让Session丢失)。事实上,后来我早就放弃了去给人解释Session机制的尝试。只给忠告:从编程的一开始就要假设将来的生产服务器每隔5~10分钟就重启应用程序一次,因此不要使用Session、static变量等来持久保存任何数据。放弃Session,你从一开始就能编写稳定的代码。
      

  7.   

    根本就没的行,网站发布后报出来的错误。已经成DLL咯。
      

  8.   

    根本就没的67行,网站发布后报出来的错误。已经成DLL咯。
      

  9.   

    用反编译器看看,要么你的代码里加一下
    If(Session[""] == null)
    {
        Response.Write("Session in NULL");
    }
    try...catch后面所有的段落,Exception不要丢出来。
      

  10.   


    如果我session丢失,那么为什么在我自己的机子上面访问服务器网页不会出现这种情况。而在别人机子上面出现了呢?如果我session丢失,在我自己的机子上面访问服务器网页和别人机子上应该也是一样的啊。关键是现在是我机子访问服务器网页正常,在别人机子上面访问服务器网页出现上述错误。如果session丢失,别人的机子上面会丢失,我机子上面就不会了吗?。我纳闷的就是这一点儿,在自己机子上面访问服务器能正常,在别人机子上就不行了的哇。