我现在想这样
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页面去怎么办???怎么写才能达到这种效果
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页面去怎么办???怎么写才能达到这种效果
解决方案 »
- asp.net怎么判断C++是否登陆
- 菜鸟求教 UI层用到业务层的代码都要try catch吗? 发生未处理的异常,如何让页面自动跳转到ErrPage页面呢?
- 数据绑定Repeater上把第一条数据与其它的数据不一样
- 分不多,题不难
- GridView 的问题,有点菜但请大家帮忙?
- 怎么让datalist显示时不换行,而是跟在前一个控件后面呢?
- ???菜鸟刚学用c#做asp.net网页,我想用Repeater1控件来显示一个表的内容,我写的怎么不好使呢?是否需要配置什么呢?
- 多次点击一个按钮的执行顺序是怎样的?
- 江湖救急,在线等候!!
- 武汉的朋友来谈谈asp.net的待遇情况?
- 给DropDownlist绑定一个客户端事件,为什么客户端事件返回为true了,而不执行服务器端事件了?
- 求”新闻发布“ASP后台程序。
response.buffer=falsh
上面的无论无何都是转到2.aspx上去的
所以...^^
和
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);