Error Reporting and the Trace in ASP.Net 2.0 -Code Update

I've just had it pointed out to me (and quite rightly so) by Craig that my code for enabling the trace with Phil Winstanley's WebException was a touch wrong. I was assuming that the user was (correctly imho) running the application with the trace already disabled. However correct that may be, it may not be the case so as pedantic as this is, the code snippet should really be:

TraceContext t = HttpContext.Current.Trace;bool bCurrentState = t.IsEnabled;t.IsEnabled = true;WebException WE = newWebException();WE.CurrentException = Server.GetLastError();xml:namespace prefix = o /WE.Handle();t.IsEnabled = bCurrentState;

Although I've adapted the code to accomodate this, I really wouldn't run production sites with the trace enabled as this is not only a performace hit but quite a security issue!

Subscribe to TSD

Don’t miss out on the latest posts. Sign up now to get access to the library of members-only posts.
jamie@example.com
Subscribe