取消Response.Redirect [英] Cancel a Response.Redirect

查看:70
本文介绍了取消Response.Redirect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

有没有办法取消?一个回应。重定向?例如,在下面的代码

中,我可以在Catch语句中插入任何会取消

重定向并在try-catch之后恢复流程的内容吗?


尝试

Response.Redirect(strPage)

Catch ex1 As Threading.ThreadAbortException

ex1 = ex1

''取消在这里回复

结束尝试

''此处继续流程


我正在尝试为包含重定向的页面编写单元测试。


感谢您的任何建议,

Tim

解决方案

你希望从Response.Redirect()中捕获什么?

我建议你看一下验证URL而不是try / catch的样本
重定向



-

Curt Christianson

所有者/首席开发人员,DF-Software

网站: http://www.Darkfalz.com

博客: http://blog.Darkfalz.com

Tim < Ti*@discussions.microsoft.com>在留言中写道

新闻:6F ********************************** @ microsof t.com ...

你好,
有没有办法取消?一个回应。重定向?例如,在下面的代码中,我可以在Catch语句中插入任何会在try-catch之后取消
重定向和恢复流程的内容吗?

尝试
Response.Redirect(strPage)
抓住ex1 As Threading.ThreadAbortException
ex1 = ex1
''取消在这里结束
结束尝试
''简历流向这里

我正在尝试为包含重定向的页面编写单元测试。

感谢您的任何建议,
Tim



Hello Curt,

我正在试图抓住正确测试的页面试图

重定向到另一个页面。


你能提供一篇讨论进一步验证URL的文章 - 我不是

看看这有助于单元测试页面。


谢谢,

Tim


Curt_C [MVP]"写道:

你期望从Response.Redirect()中捕获什么?
我建议你看一下验证URL而不是try / catch的示例
重定向

-
Curt Christianson
所有者/首席开发人员,DF-Software
网站: http://www.Darkfalz.com
博客: http://blog.Darkfalz.com

" Tim" < Ti*@discussions.microsoft.com>在消息中写道
新闻:6F ********************************** @ microsof t.com。 ..

你好,
有没有办法取消一个回应。重定向?例如,在下面的代码中,我可以在Catch语句中插入任何会在try-catch之后取消
重定向和恢复流程的内容吗?

尝试
Response.Redirect(strPage)
抓住ex1 As Threading.ThreadAbortException
ex1 = ex1
''取消在这里结束
结束尝试
''简历流向这里

我正在尝试为包含重定向的页面编写单元测试。

感谢您的任何建议,
Tim




Response.Redirect接受两个参数,第二个是中止

当前线程或继续执行。也许考虑到这一点,它可能会为你的事业提供帮助。

恩里克。

" Tim" < Ti*@discussions.microsoft.com>在留言中写道

新闻:6F ********************************** @ microsof t.com ...

你好,
有没有办法取消?一个回应。重定向?例如,在下面的代码中,我可以在Catch语句中插入任何会在try-catch之后取消
重定向和恢复流程的内容吗?

尝试
Response.Redirect(strPage)
抓住ex1 As Threading.ThreadAbortException
ex1 = ex1
''取消在这里结束
结束尝试
''简历流向这里

我正在尝试为包含重定向的页面编写单元测试。

感谢您的任何建议,
Tim



Hello,
Is there a way to "cancel" a response.Redirect? For example, in the code
below, could I insert anything in the Catch statement that would cancel the
redirect and resume flow after the try-catch?

Try
Response.Redirect(strPage)
Catch ex1 As Threading.ThreadAbortException
ex1 = ex1
''Cancel Respone here
End Try
''Resume flow here

I am trying to write unit tests for pages that include Redirects.

Thanks for any advice,
Tim

解决方案

What is it you expect to catch from a Response.Redirect() ?
I suggest you look at a sample of validating a URL instead of the try/catch
on the redirect

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...

Hello,
Is there a way to "cancel" a response.Redirect? For example, in the code
below, could I insert anything in the Catch statement that would cancel
the
redirect and resume flow after the try-catch?

Try
Response.Redirect(strPage)
Catch ex1 As Threading.ThreadAbortException
ex1 = ex1
''Cancel Respone here
End Try
''Resume flow here

I am trying to write unit tests for pages that include Redirects.

Thanks for any advice,
Tim



Hello Curt,
I''m trying to "catch" that the page being tested correctly tried to
Redirect to another page.

Can you provide an article that discusses further validating a URL - I''m not
seeing how this would help unit test the page.

Thanks,
Tim

"Curt_C [MVP]" wrote:

What is it you expect to catch from a Response.Redirect() ?
I suggest you look at a sample of validating a URL instead of the try/catch
on the redirect

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...

Hello,
Is there a way to "cancel" a response.Redirect? For example, in the code
below, could I insert anything in the Catch statement that would cancel
the
redirect and resume flow after the try-catch?

Try
Response.Redirect(strPage)
Catch ex1 As Threading.ThreadAbortException
ex1 = ex1
''Cancel Respone here
End Try
''Resume flow here

I am trying to write unit tests for pages that include Redirects.

Thanks for any advice,
Tim




Response.Redirect accepts two parameters the second being to abort the
current thread or continue with execution. Maybe look into that, it might
help your cause.
Enrique.
"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...

Hello,
Is there a way to "cancel" a response.Redirect? For example, in the code
below, could I insert anything in the Catch statement that would cancel
the
redirect and resume flow after the try-catch?

Try
Response.Redirect(strPage)
Catch ex1 As Threading.ThreadAbortException
ex1 = ex1
''Cancel Respone here
End Try
''Resume flow here

I am trying to write unit tests for pages that include Redirects.

Thanks for any advice,
Tim



这篇关于取消Response.Redirect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆