In my global.asax page I have the following code:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
server.transfer("err.aspx")
End Sub
It does not work and I get the folowing error: Object reference not set to an instance of an object.
Thanks in advance
I would recommend using the built-in error handling in .NET for this, just use Web.config:
The
responseRewrite
will make it act as a Server.Transfer. If you want a redirect instead, useredirectMode="responseRedirect"
.More info here:
However, if you really want to handle it in Global.asax, you should use the
sender
object: