In my web application I captured all unhanded exceptions by using the following method:
1)In web.config, add:
<customErrors mode="RemoteOnly" defaultRedirect="error.aspx" />
2)In global.asax.
vb, add:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Fires when an error occurs
Dim Mymessage As New MailMessage
SmtpMail.Send("
[email protected]", "
[email protected]", "Error occurs", Request.Path & Server.GetLastError.ToString())
End Sub
Everything works fine.
As far as I understand, the âRemoteOnlyâ is an option that only allows users who access the web application from the local machine (localhost) to see the exception information, while all other users will be redirected to the defaultredirect page (âerror.aspxâ in my case).
My web application is available to companyâs intranet users as well as Internet users, how could I allow all users inside the company see the detailed exception information, and redirect all outside users to âerror.aspx?
Could I possible detect the userâs IP address at this stage, then according to the useâs IP address to decide whether to redirect the user or not?
Any suggestions would be very appreciated.
Thank you!