.net 页面跳转,本机正常,服务器上就不正常了
代码如下:
indexqx.aspx的代码
protected void Page_Load(object sender, EventArgs e)
     {
         if ((bool)Session["emp_loginok"])
             {                     
             }
             else
             {
                Response.Redirect("loginqx.aspx");
             }
     }
loginqx.aspx代码
     protected void LoginB_Click(object sender, EventArgs e)
{
     .
     .
     .
     .
     //对密码与帐号的判断
     Session["emp_loginok"] = true;
     Response.Redirect("indexqx.aspx");
}
Global.asax中代码:
     void Session_Start(object sender, EventArgs e)  
     {
         Session["emp_loginok"] = false;
     }
在自己的机子上可以很正常的跳转,但到了服务器上,就出了问题.
问题的现象是:当密码与帐号输入正确后,但总是跳不到indexqx.aspx页面.
还请各位前辈们帮下忙!
------解决方案--------------------indexqx.aspx的代码  
protected void Page_Load(object sender, EventArgs e)  
   {  
       if ((bool)Session["emp_loginok"])  
           {                  
           }  
           else  
           {  
             Response.Redirect("loginqx.aspx");  
           }  
   }  
loginqx.aspx代码  
   protected void LoginB_Click(object sender, EventArgs e)  
{  
   .  
   .  
   .  
   .  
   //对密码与帐号的判断  
   Session["emp_loginok"] = true;  
  this.Response.Write(Session["emp_loginok"].ToString());
看看这里打印出来有没有值,没有或者报错的话,就是 Session 没有写入。
   Response.Redirect("indexqx.aspx");  
}  
Global.asax中代码:  
   void Session_Start(object sender, EventArgs e)  
   {  
       Session["emp_loginok"] = false;  
   }  
------解决方案--------------------应该没问题,Session里面存Bool类型的,ToString()出来就是"true" or "false"  
不过由于系统或IIS的不一样,还是ToString()出来看看,楼主应该是XP吧
------解决方案--------------------以后尽量不要用SESSION 学习一下用VIEWSTATE,用法和SESSION差不多,但是不会出现莫名其妙的问题。
------解决方案--------------------Session变量的有效期是不定的,即使是设定了超时时间好像也不起作用。
当服务器繁忙的时候,Session经常会丢失。
所以在使用session的时候,经常要判断Session[["emp_loginok"] == null,
才能继续下去,不判断而使用Session会报错。
你想页面之见传值用其他方法,用URL或者其他,
若只是想在当前页面保留值,用viewstate.
------解决方案--------------------
------解决方案--------------------只用  
Response.Write(Session["trytry"].ToString());  
的话能正常显示出"中华人民共和国"  
但加上  
Response.Write(Session["emp_loginok"].ToString());  
后就出现了下能的提示  
“/bdqx”应用程序中的服务器错误。  
--------------------------------------------  
未将对象引用设置到对象的实例。  
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  
异常详细信息: 
System.NullReferenceException: 未将对象引用设置到对象的实例。  源错误:  
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 
堆栈跟踪:  
                         这种写法是什么意思呀?该如何处理