在本地上运行的好好的 ,传到服务器上就报这个错误了,而且除了首页其他的页面都访问得到,急啊!高手在哪里
具体报的错误贴在下边了。
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
[NullReferenceException: 未将对象引用设置到对象的实例。]
   jbjy.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\12-22\jbjy\WebForm1.aspx.cs:71
   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 
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.3643; ASP.NET 版本:2.0.50727.3634 

解决方案 »

  1.   

    aspx.cs:71,告诉你第几行了,调试
      

  2.   

    贴点代码出来!本地调试通不代表服务器就可以。就好比本地调用你本地的webservice取值如果挂到服务器上没改配置文件或者调用的路径不对同样也有可能报这种错误
      

  3.   

    配置文件是改了的  主要在服务器上没有环境,不然我也就调试了,首页的cs代码:
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Xml.Linq;
    using jbjy.DAO;
    using jbjy.Common;
    using System.Collections.Generic;
    namespace jbjy
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            SqlOpearaClass sqlopearaclass = new SqlOpearaClass();
            ED_JB_NewsInfo newsinfo = new ED_JB_NewsInfo();
            public int XXHJId = 0;
            protected void Page_Load(object sender, EventArgs e)
            {
                if (Request["XXHJId"] != null)
                {
                    XXHJId = Convert.ToInt32(Request["XXHJId"]);
                }
                else
                {
                    XXHJId = 1;
                }
                    ED_JB_RegisterInfo user = Session["userinfo"] as ED_JB_RegisterInfo;
                    if (HttpContext.Current.Request.Cookies["cqjbjy"] == null && user != null)
                    {
                        HttpCookie cookiejbjy = new HttpCookie("cqjbjy");
                        cookiejbjy.Values.Add("cqjbjyid", user.RegisterId.ToString());
                        Response.AppendCookie(cookiejbjy);
                        cookiejbjy.HttpOnly = false;
                        getlogin();
                    }
                    else if (user == null && HttpContext.Current.Request.Cookies["cqjbjy"] != null)
                    {
                        HttpCookie cookie = HttpContext.Current.Request.Cookies["cqjbjy"];
                        ED_JB_RegisterInfo userInfo = sqlopearaclass.QueryregisterListUserId(int.Parse(cookie["cqjbjyid"].ToString()))[0];
                        Session.Add("userinfo", userInfo);
                        getlogin();
                    }
                    else if (user == null && HttpContext.Current.Request.Cookies["cqjbjy"] == null)
                    {
                        this.Panel1.Visible = true;
                        this.Panel2.Visible = false;
                    }
                    else
                    {
                        getlogin();
                    }
                    //主要新闻
                    List<ED_JB_NewsInfo> newList = sqlopearaclass.QueryNewList();
                    if (newList.Count > 0)
                    {
                        newsinfo = newList[0];
                        foreach (ED_JB_NewsInfo item in newList)
                        {
                            if (item.TiQuContent.Length > 101)
                            {
                                item.TiQuContent = item.TiQuContent.Substring(0, 100) + "...";
                            }
                        }
                        foreach (ED_JB_NewsInfo item in newList)
                        {
                            if (item.NewTitle.Length > 26)
                            {
                                item.NewTitle = item.NewTitle.Substring(0, 25) + "...";
                            }
                        }
                        this.Repeater1.DataSource = newList;
                        this.Repeater1.DataBind();
                    }
                    //图片新闻
                    List<ED_JB_NewsInfo> newtpxwList = sqlopearaclass.QueryNewtpxwList();
                    if (newList.Count > 0)
                    {
                        newsinfo = newtpxwList[0];
                        foreach (ED_JB_NewsInfo item in newtpxwList)
                        {
                            if (item.NewTitle.Length > 21)
                            {
                                item.NewTitle = item.NewTitle.Substring(0, 20);
                            }
                        }
                        this.Repeater2.DataSource = newtpxwList;
                        this.Repeater2.DataBind();
                    }
                    rptDatanind();
                 }        private void getlogin()
            {
                ED_JB_RegisterInfo user = Session["userinfo"] as ED_JB_RegisterInfo;
                //登陆成功信息
                List<ED_JB_RegisterInfo> registerlist = sqlopearaclass.Queryregisterlist(user.MemberName);
                sqlopearaclass.UpdateLoginDateTime(registerlist[0].RegisterId);
                ED_JB_RegisterInfo registerinfo = registerlist[0];
                this.lblusername.Text = registerinfo.MemberName;
                this.lblNiceName.Text = registerinfo.NiceName;
                this.lblshangcidengluDatetime.Text = Convert.ToDateTime(registerinfo.DLDatetime).ToString("yyyy-MM-dd hh:mm:ss");
                //变量,多少天没登陆
                this.lblCountDay.Text = (DateTime.Now - registerinfo.DLDatetime.Value).Days.ToString();
                this.Panel1.Visible = false;
                this.Panel2.Visible = true;
            }
            public void rptDatanind()
            {
                //新闻列表
                List<ED_JB_NewsInfo> newsInfoList = sqlopearaclass.QueryNewInfoList();
                if (newsInfoList.Count > 0)
                {
                    foreach (ED_JB_NewsInfo item in newsInfoList)
                    {
                        if (item.NewTitle.Length > 21)
                        {
                            item.NewTitle = item.NewTitle.Substring(0, 20) + "...";
                        }
                    }
                    this.rptnewlist.DataSource = newsInfoList;
                    this.rptnewlist.DataBind();
                }
                //网络课程视频
                List<ED_JB_WLKCInfo> wlkclist = sqlopearaclass.Querywlkclist();
                this.Repeater3.DataSource = wlkclist;
                this.Repeater3.DataBind();
                //网络课程列表
                List<ED_JB_WLKCInfo> wlkcinfoList = sqlopearaclass.QuerywlkcInfolist();
                if (wlkcinfoList.Count > 0)
                {
                    foreach (ED_JB_WLKCInfo item in wlkcinfoList)
                    {
                        if (item.WLKCTitle.Length > 19)
                        {
                            item.WLKCTitle = item.WLKCTitle.Substring(0, 18);
                        }
                    }
                    this.rptwangluokechenglist.DataSource = wlkcinfoList;
                    this.rptwangluokechenglist.DataBind();
                }
               //学习园地
                List<ED_JB_LearGardenerInfo> learGarenerList = sqlopearaclass.QueryLearGarenerList();
                if (learGarenerList.Count > 0)
                {
                    foreach (ED_JB_LearGardenerInfo item in learGarenerList)
                    {
                        if (item.LearGardenerTitel.Length > 31)
                        {
                            item.LearGardenerTitel = item.LearGardenerTitel.Substring(0, 30) + "...";
                        }
                    }
                    this.rptxuexiyuandi.DataSource = learGarenerList;
                    this.rptxuexiyuandi.DataBind();
                }
                //会计知识
                List<ED_JB_KJZSInfo> kuaijizhshiList = sqlopearaclass.QuerykuaijizhshiList();
                if (kuaijizhshiList.Count > 0)
                {
                    foreach (ED_JB_KJZSInfo item in kuaijizhshiList)
                    {
                        if (item.KJZSTitle.Length > 16)
                        {
                            item.KJZSTitle = item.KJZSTitle.Substring(0, 14) + "...";
                        }
                    }
                }
                this.rptkuaijizhishi.DataSource = kuaijizhshiList;
                this.rptkuaijizhishi.DataBind();
                //在线答疑
                List<ED_JB_ZXYDInfo> zaixianyidaList = sqlopearaclass.QueryzaixianyidaList();
                if (zaixianyidaList.Count > 0)
                {
                    foreach (ED_JB_ZXYDInfo item in zaixianyidaList)
                    {
                        if (item.ZXYDQuestion.Length > 13)
                        {
                            item.ZXYDQuestion = item.ZXYDQuestion.Substring(0, 12) + "...";
                        }
                    }
                }
                this.rptzaixiandayi.DataSource = zaixianyidaList;
                this.rptzaixiandayi.DataBind();
                //单位招聘
                List<ED_JB_DWZPInfo> danweizhaopinglist = sqlopearaclass.Querydanweizhaopinglist();
                if (danweizhaopinglist.Count > 0)
                {
                    foreach (ED_JB_DWZPInfo item in danweizhaopinglist)
                    {
                        if (item.DWZPTitle.Length > 16)
                        {
                            item.DWZPTitle = item.DWZPTitle.Substring(0, 15) + "...";
                        }
                    }
                }
                this.rptDanweizhaoping.DataSource = danweizhaopinglist;
                this.rptDanweizhaoping.DataBind();
                //资料下载
                List<ED_JB_LanmuInfo> lanmu = sqlopearaclass.queryzilaioxiazailist();
                this.rptzlxz.DataSource = lanmu;
                this.rptzlxz.DataBind();
                 //资料下载图片
                List<ED_JB_XXZLXZInfo> ziliaoxiazaiList = sqlopearaclass.QueryziliaoxiazaiList(lanmu[0].LanMuId);
                this.rptzlxzImage.DataSource = ziliaoxiazaiList;
                this.rptzlxzImage.DataBind();
                List<ED_JB_XXZLXZInfo> ziliaoxiazainewList = sqlopearaclass.QueryziliaoxiazainewList(lanmu[0].LanMuId);
                foreach (ED_JB_XXZLXZInfo item in ziliaoxiazainewList)
                {
                    if (item.ChirldLanMuName.Length > 31)
                    {
                        item.ChirldLanMuName = item.ChirldLanMuName.Substring(0, 31) + "...";
                    }
                }
                this.rptzlxzList.DataSource = ziliaoxiazainewList;
                this.rptzlxzList.DataBind();
                // 校园环境
                List<ED_JB_XXHJInfo> xiaoyuanhuanjingList = sqlopearaclass.QueryxiaoyuanhuanjingLis();
                this.rptxiaoyuanhuanjing.DataSource = xiaoyuanhuanjingList;
                this.rptxiaoyuanhuanjing.DataBind();
                //环境图片
                List<ED_JB_XXHJImageInfo> xiaoyuanhuanjingImageList = sqlopearaclass.QueryxiaoyuanhuanjingImageListt(XXHJId);
                this.rpttp.DataSource = xiaoyuanhuanjingImageList;
                this.rpttp.DataBind();
            }
           
      

  4.   

     protected void rptxiaoyuanhuanjing_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                List<ED_JB_XXHJImageInfo> xiaoyuanhuanjingImageList = sqlopearaclass.QueryxiaoyuanhuanjingImageListt(int.Parse(e.CommandArgument.ToString()));
                this.rpttp.DataSource = xiaoyuanhuanjingImageList;
                this.rpttp.DataBind();
                ScriptManager.RegisterStartupScript(this.rpttp, this.rpttp.GetType(), "",
                    "clearInterval(sliding);$('.hengtiaobj a').removeClass('ht_sel');$('#" + e.Item.ClientID + @"_LinkButton1').addClass('ht_sel');_slide = $('#slide');_slideli1 = $('.slideli1');
                     _slideli2 = $('.slideli2');_slideli2.html(_slideli1.html());sliding=setInterval(Marquee,_speed);", true);
            }
            protected void rptzlxz_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                //资料下载图片
                List<ED_JB_XXZLXZInfo> ziliaoxiazaiList = sqlopearaclass.QueryziliaoxiazaiList(int.Parse(e.CommandArgument.ToString()));
                this.rptzlxzImage.DataSource = ziliaoxiazaiList;
                this.rptzlxzImage.DataBind();
                ScriptManager.RegisterStartupScript(this.rptzlxzList, this.rptzlxzList.GetType(), "",
                  "$('.xiazai a').removeClass('nav_sel');$('#" + e.Item.ClientID + @"_LinkButton2').addClass('nav_sel');", true);
                List<ED_JB_XXZLXZInfo> ziliaoxiazainewList = sqlopearaclass.QueryziliaoxiazainewList(int.Parse(e.CommandArgument.ToString()));
                foreach (ED_JB_XXZLXZInfo item in ziliaoxiazainewList)
                {
                    if (item.ChirldLanMuName.Length > 31)
                    {
                        item.ChirldLanMuName = item.ChirldLanMuName.Substring(0, 31) + "...";
                    }
                }
                this.rptzlxzList.DataSource = ziliaoxiazainewList;
                this.rptzlxzList.DataBind();
                ScriptManager.RegisterStartupScript(this.rptzlxzList, this.rptzlxzList.GetType(), "",
                    "$('.xiazai a').removeClass('nav_sel');$('#" + e.Item.ClientID + @"_LinkButton2').addClass('nav_sel');", true);
            }
            /// <summary>
            /// 会员登录
            /// </summary
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
            {
                if (Request["admchkCode"] != null && Request["admchkCode"] != "" && this.txtusername.Text.Trim() != null && this.txtusername.Text.Trim() != "" && this.txtpassword.Text.Trim() != null && this.txtpassword.Text.Trim() != "")
                {
                    if (Session["admchkCode"] != null)
                    {
                        //验证码不相同
                        if (Session["admchkCode"].ToString().ToLower() != Request["admchkCode"].ToString().ToLower())
                        {
                            this.divorr.InnerText = "验证码错误";
                        }
                        else
                        {
                            string nam = this.txtusername.Text.Trim();
                            string pas = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtpassword.Text.Trim(), "SHA1");
                            ED_JB_RegisterInfo user = sqlopearaclass.RegisterIsNotHave(nam, pas);
                            if (user != null)
                            {
                                Session.Add("userinfo", user); 
                                this.Panel1.Visible = false;
                                this.Panel2.Visible = true;
                                HttpCookie cookie =new  HttpCookie("cqjbjy");
                                cookie.Values.Add("cqjbjyid", user.RegisterId.ToString()); 
                                Response.AppendCookie(cookie);
                                cookie.HttpOnly = false;
                                //登陆成功信息
                                    List<ED_JB_RegisterInfo> registerlist = sqlopearaclass.Queryregisterlist(user.MemberName);
                                    sqlopearaclass.UpdateLoginDateTime(registerlist[0].RegisterId);
                                    ED_JB_RegisterInfo registerinfo = registerlist[0];
                                    this.lblusername.Text = registerinfo.MemberName;
                                    this.lblNiceName.Text = registerinfo.NiceName;
                                    this.lblshangcidengluDatetime.Text = Convert.ToDateTime(registerinfo.DLDatetime).ToString("yyyy-MM-dd hh:mm:ss");
                                    //变量,多少天没登陆
                                    this.lblCountDay.Text = (DateTime.Now - registerinfo.DLDatetime.Value).Days.ToString();
                            }
                            else
                            {
                                this.divorr.InnerText = "请确认您的用户名或密码";
                            }
                        }
                    }
                }
            }
          }
    }
      

  5.   

    好长的意大利面条,大体一看没有注意到给Session赋值的地方只注意到使用Session的地方了
      

  6.   

    ED_JB_RegisterInfo user = Session["userinfo"] as ED_JB_RegisterInfo;
    这里使用的Session["userinfo"] 赋值了吗?