G
Guest
I wrote a very simple httpmodule and tried to compile it with no success.
This is my code:
==============
Imports System
Imports System.Web
Imports Microsoft.VisualBasic
NameSpace myErrorHandler
Public Class myExceptionHandler
Implements IHttpModule
Public Sub Init (objApp as HttpApplication)
AddHandler objApp.Error, AddressOf Me.OnError
End sub
Public Sub Dispose()
End Sub
Public Sub OnError(Sender as Object, e as EventArgs)
Dim objApp as HttpApplication
objApp = CType(Sender, HttpApplication)
Dim ctx as HttpContext = objApp.Context.Current
Dim exception as Exception = ctx.Server.GetLastError()
Dim errorInfo as string = _
"<br>Offending URL: " & ctx.Request.Url.ToString() & _
"<br>Source: " & exception.Source & _
"<br>Message: " & exception.Message & _
"<br>Stack trace: " & exception.StackTrace
ctx.Response.Write (errorInfo)
End Sub
End Class
End Namespace
==============
I am not too sure how to compile the above code because whenever I tried it,
the vbc compiler said that I have to have init and dispose in order to
implement the IHttpModule interface. The problem is, I do have those 2 subs
in my class?
Can someone point out what's wrong with my code for me?
I used the following command in C:\WINNTS\Microsoft.NET\Framework\v1.1.4322
to compile the code:
vbc /t:library /r:System.dll,System.web.dll PGDErrorHandler.vb
This is my code:
==============
Imports System
Imports System.Web
Imports Microsoft.VisualBasic
NameSpace myErrorHandler
Public Class myExceptionHandler
Implements IHttpModule
Public Sub Init (objApp as HttpApplication)
AddHandler objApp.Error, AddressOf Me.OnError
End sub
Public Sub Dispose()
End Sub
Public Sub OnError(Sender as Object, e as EventArgs)
Dim objApp as HttpApplication
objApp = CType(Sender, HttpApplication)
Dim ctx as HttpContext = objApp.Context.Current
Dim exception as Exception = ctx.Server.GetLastError()
Dim errorInfo as string = _
"<br>Offending URL: " & ctx.Request.Url.ToString() & _
"<br>Source: " & exception.Source & _
"<br>Message: " & exception.Message & _
"<br>Stack trace: " & exception.StackTrace
ctx.Response.Write (errorInfo)
End Sub
End Class
End Namespace
==============
I am not too sure how to compile the above code because whenever I tried it,
the vbc compiler said that I have to have init and dispose in order to
implement the IHttpModule interface. The problem is, I do have those 2 subs
in my class?
Can someone point out what's wrong with my code for me?
I used the following command in C:\WINNTS\Microsoft.NET\Framework\v1.1.4322
to compile the code:
vbc /t:library /r:System.dll,System.web.dll PGDErrorHandler.vb