我现在想这样
try
{
   if(light=1)
       {
         label1.text="2323"; 
       }
   else
   {
      Response.redirect("1.aspx");
   }
}
catch
{
    Response.redirect("2.aspx");}
但结果发现事实上1.aspx根本无法转到,测试了半天,发现了问题所在try
{
Response.redirect("1.aspx");
}
catch
{
Response.redirect("2.aspx");
}
这么写也根本转不到1.aspx页面去怎么办???怎么写才能达到这种效果

解决方案 »

  1.   

    试一下加上这句
    response.buffer=falsh
      

  2.   

    看看你的路径写的是否正确,你当前页面和1.aspx是否在同以目录下!
      

  3.   

    如果我没记错的话
    上面的无论无何都是转到2.aspx上去的
      

  4.   

    if(light==1)应该这个也是一个问题,但是后面没用到这个也没转过去,你是在那里用呢,后台,还是类?
      

  5.   

    Response.Redirect操作总是会引发HttpException
    所以...^^
      

  6.   

    解决办法就是把Response.Redirect写在try/catch外面
      

  7.   

    Response.redirect("1.aspx");是一个过程 怎么可以放在try里面的呀
      

  8.   

    Response.Redirect 
    和 
    Response.end 内部都调用了Thread.Abort() 
    大概是该方法就是用来终止线程的那个方法 该方发会抛出ThreadAbortException 异常 
    该异常是一个独特的异常,不会被catch吃掉 
    他会一直传递到最上层,该特性使得线程终止的时候所有的finally块都会执行,用来释放资源 A thread is executing your application in terms of ASP.NET worker process , when you call Response.Redirect(URL);In your code then to redirect to the new URL specified by you ASP.NET framework must be told to stop the current execution of the page and to transfer the execution to the URL page specified in the method call. This is done in a 2 way step :- 1)       Response.End() is called internally by Response.Redirect to stop the current execution and the ThreadAbortException is thrown.2)       .NET framework will call catch “ThreadAbortException” and stop current execution and start executing the new page.   Now during the Step #1 Response.End will throw out a  “ThreadAbortException” to let .NET framework know that the current execution needs to be stopped and the execution of new should begin.    Asp.net framework catches the Redirect method's exception, aborts the thread and use a new thread for execution of to be redirected page. Solution :- The way to get over this problem is to specify Response.Redirect(URL,false) , this will tell .NET framework not to stop the execution of the current thread and hence the error will be resolved.  “ThreadAbortException” is a special kind of an exception even if you catch it in a catch block even then it will be raised again at the end of the catch block. When this exception is raised, the runtime executes all the finally blocks before killing the thread.Response.redirect("1.aspx",false);