Исключение WebMethod не перехвачено пользовательским HttpModule - PullRequest
0 голосов
/ 26 сентября 2019

Попытка зарегистрировать исключения из WebMethods в приложении WebForms ASP.NET

Public Class ExceptionModule
    Implements IHttpModule

    Public Sub Init(context As HttpApplication) Implements IHttpModule.Init

        'break point reaches here

        AddHandler AppDomain.CurrentDomain.UnhandledException, New UnhandledExceptionEventHandler(AddressOf CurrentDomain_UnhandledException)
        AddHandler context.Error, New EventHandler(AddressOf Context_Error)

    End Sub

    Public Sub Dispose() Implements IHttpModule.Dispose
    End Sub

    Private Sub CurrentDomain_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs)

        'break point never reaches here

    End Sub

    Private Sub Context_Error(sender As Object, e As EventArgs)

        'break point never reaches here

    End Sub

End Class

Я использую IIS в классическом неинтегрированном режиме.Итак, в Web.Config у меня есть:

<httpModules>
    <add name="ExceptionModule" type="MyNameSpace.ExceptionModule, MyAssembly" />
</httpModules>

Итак, я помещаю некоторые точки останова в класс ExceptionModule, и функция Init () вызывается, а другие (CurrentDomain_UnhandledException и Context_Error) нет, даже когда искусственно выбрасываетсяисключение в WebMethod.

...