Solution given by Hiren is Good.
You can also achieve the same using Global.asax.
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim ctx As HttpContext = HttpContext.Current
Dim exception As Exception = ctx.Server.GetLastError
Dim errInfo As String = "<br>Error In : " & ctx.Request.Url.ToString() & _
"<br>Source:" & exception.Source & _
"<br>Message: " & exception.Message
ctx.Response.Write(errInfo)
ctx.Server.ClearError()
Session("value") = errInfo
System.Web.HttpContext.Current.Response.Redirect("~/ErrorPage.aspx")
End Sub
Regards