日期:2014-05-20  浏览次数:20491 次

为什么这里无法Catch 到异常-Page_PreInit?
Protected   Sub   Page_PreInit(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   Me.PreInit
                If   Not   Request.Cookies( "webStyle ")   Is   Nothing   Then
                        Try
                                Page.Theme   =   Request.Cookies( "webStyle ").Values( "Style ")
                        Catch   exHttpException   As   HttpException
                                Response.Write(exHttpException.Message.ToString)
                        Catch   exNone   As   Exception
                                Response.Write(exNone.Message.ToString)
                        End   Try
                End   If
        End   Sub
这段程序,其中webStyle,以及其中的Style值有均存在,但是我故意指定了一个我程序中不存在的主题.其中Style代表主题名称,看Cookie
webStyle
Style=zh-tt
其中zh-tt在我的程序中是一个不存在的主题,但是在   Page.Theme   执行时,却无法正常Catch到,而我在application_error中却可以捕获,请问,为什么在页的catch   中无法捕获异常.

------解决方案--------------------
那可能就是异常不是你些再try中的这两类,
再加一类Exception应该就抓到了
------解决方案--------------------
UP