Last post Sep 04, 2010 11:45 PM by dch3
Sep 04, 2010 04:45 PM|dch3|LINK
The code below demonstrates how to signal an error in the ELMAH error log without throwing an exception. This specific bit of code captures the browser name and version number that the user utilized to access the site. Given that it is an intranet site that
we're very heavily pushing, we anticipate that we'll finally be able to track down the machines out there that are still running older browsers. We've already upgraded several already. I'm now looking into options that will let us filter out the actual exceptions
from the logged events.
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
'Move code here that sets the User Session Variables, currently done in the code behind of DefaultDirectory and the Dashboard Masters
Dim ExceptionMessage As New StringBuilder
ExceptionMessage.Append("Site accessed using " + Request.Browser.Browser + " " + Request.Browser.MajorVersion.toString + "." + Request.Browser.MinorVersion.tostring)
Dim NewException As New NotSupportedException(ExceptionMessage.ToString)
Sep 04, 2010 08:39 PM|thuhue|LINK
Where and how can we apply what you said?
What do we need to import, install or set reference to?
What do we need to add or change in Web.Config?
Sep 04, 2010 11:45 PM|dch3|LINK
You'll need to get ELMAH up and running. Once its up and running, then it should just be a matter of copying and pasting the code into your global.asax. If you go with a table in SQL Server for the ELMAH logging, be certain that you grant execute permissions
on the ELMAH stored procedures.