重定向 [英] REdirecting

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

问题描述




如何从组件vb.net重定向到错误页面?


Public Class bo


受保护的朋友函数CreateString(ByRef lst作为ListBox)作为字符串


dim s As String


试试


s =" Hello World"


''创建一个新数据集


Catch ex作为例外


''如何从这里使用Response.Redirect(" page.aspx")???


跟踪。写(ex.Message)


最后


结束尝试


返回s


结束功能


结束班级


谢谢,


Yama

解决方案

不要从组件内重定向。这些决定属于上层

应用程序层。只需在下面的例子中提出异常,并让

上面的图层处理如何报告错误。


" Yama" < YK ***** @ grandpacificresorts.com>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ...



如何从组件vb.net重定向到错误页面?

公共类bo

受保护的朋友函数CreateString(ByRef lst As ListBox)作为字符串

dim s As String

尝试

s =" Hello World"

''创建一个新数据集

Catch ex As Exception

''如何从这里使用Response.Redirect(" page.aspx")???

Trace.Write(ex.Message)

最后

结束尝试

返回s

结束功能

结束课

谢谢,

Yama



你好尼克,


我怎么知道它引发了异常?我该如何验证呢?我不希望
希望网络崩溃。我宁愿向用户返回描述性错误消息

.


Yama


" Nick" < FR ** @ here.there>在消息中写道

新闻:uY **************** @ TK2MSFTNGP10.phx.gbl ...

不要重定向在组件内。这些决定属于
上层应用程序层。只需在下面的例子中提出异常,并让上面的图层处理如何报告错误。

Yama < YK ***** @ grandpacificresorts.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ...



如何从组件vb.net重定向到错误页面?

公共类bo

受保护的朋友函数CreateString(ByRef lst作为ListBox)As String

dim s As String

尝试

s =" Hello World"

''创建新的数据集

Catch ex As Exception

''如何从这里使用Response.Redirect(" page.aspx")???

Trace.Write(ex.Message)

最后

结束尝试

返回s

结束功能
结束课

谢谢,

Yama




Yama试试这个

使用

Response.Redirect(" page.aspx",false)


尝试


s =" Hello World"


''创建新数据集


Catch ex As Exception


''如何从这里使用Response.Redirect(" page.aspx")???


''你可以像这样在这里使用Response.Redirect(" Page.aspx")
Response.Redirect(" Page.aspx",false)


Trace.Write(ex.Message)


最后


结束尝试


理由是尝试& Catch将在一个线程下工作。因此,如果它不会执行结束尝试此线程不会中止。在此之前,如果您尝试重定向打开的线程,它将抛出错误。为了中止这个单线程,使用Response.redirect的第二个参数为false。


这将中止你的try单线程并转到重定向页面。

默认Response.redirect将第二个参数设为true。


如果你想查看错误案例的详细信息


you可以这样做

Response.redirect(" page.aspx?errText ="& e.tostring",false)


在你的页面中。 aspx


你可以打印


Response.write(Request.querystring(" errText")


Hi,

How can I redirect to an error page from a component vb.net?

Public Class bo

Protected Friend Function CreateString(ByRef lst As ListBox) As String

dim s As String

Try

s = "Hello World"

'' create a new dataset

Catch ex As Exception

'' How can I use Response.Redirect("page.aspx") from here???

Trace.Write(ex.Message)

Finally

End Try

Return s

End Function

End Class

Thanks,

Yama

解决方案

Dont redirect from within the component. Such decisions belong in the upper
application layer. Simply raise the exception in the case below, and let
the layer above deal with how to report the error.

"Yama" <yk*****@grandpacificresorts.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Hi,

How can I redirect to an error page from a component vb.net?

Public Class bo

Protected Friend Function CreateString(ByRef lst As ListBox) As String

dim s As String

Try

s = "Hello World"

'' create a new dataset

Catch ex As Exception

'' How can I use Response.Redirect("page.aspx") from here???

Trace.Write(ex.Message)

Finally

End Try

Return s

End Function

End Class

Thanks,

Yama



Hi Nick,

How would I know it threw an exception? How can I validate for it? I don''t
want the web to crash. I would rather return a descriptive error message to
the user.

Yama

"Nick" <fr**@here.there> wrote in message
news:uY****************@TK2MSFTNGP10.phx.gbl...

Dont redirect from within the component. Such decisions belong in the upper application layer. Simply raise the exception in the case below, and let
the layer above deal with how to report the error.

"Yama" <yk*****@grandpacificresorts.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Hi,

How can I redirect to an error page from a component vb.net?

Public Class bo

Protected Friend Function CreateString(ByRef lst As ListBox) As String

dim s As String

Try

s = "Hello World"

'' create a new dataset

Catch ex As Exception

'' How can I use Response.Redirect("page.aspx") from here???

Trace.Write(ex.Message)

Finally

End Try

Return s

End Function

End Class

Thanks,

Yama




Yama Try this
Use
Response.Redirect("page.aspx",false)

Try

s = "Hello World"

'' create a new dataset

Catch ex As Exception

'' How can I use Response.Redirect("page.aspx") from here???

'' you can use Response.Redirect("Page.aspx") here like this
Response.Redirect("Page.aspx",false)

Trace.Write(ex.Message)

Finally

End Try

Reason is Try & Catch will work under a thread. So if it will not execute end try this thread is not aborted. Before that if you try to redirect a open thread it will throw error. For aborting this single thread use Response.redirect''s second parameter to false.

this will abort your try single thread and move on to redirected page.

Default Response.redirect has 2nd parameter as true.

if you want to see the detail of error case

you can do this
Response.redirect("page.aspx?errText=" & e.tostring",false)

in your page.aspx

you can print

Response.write(Request.querystring("errText")


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

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