Do you use Trace.Fail or set AssertUIEnabled="true" in your web.config?

Updated by Brady Stroud [SSW] 1 year ago. See history

123

<introEmbed
  body={<>
Have you ever seen dialogs raised on the server-side? These dialogs would hang the thread they were on, and hang IIS until they were dismissed. In this case, you might use Trace.Fail or set AssertUIEnabled="true" in your web.config.
  </>}
/>
See Scott's blog [Preventing Dialogs on the Server-Side in ASP.NET or Trace.Fail considered Harmful](http://www.hanselman.com/blog/PreventingDialogsOnTheServerSideInASPNETOrTraceFailConsideredHarmful.aspx)
 public static void ExceptionFunc(string strException)
{
    System.Diagnostics.Trace.Fail(strException);
}
Figure: Never use Trace.Fail &lt;configuration&gt;
   &lt;system.diagnostics&gt;
      &lt;assert AssertUIEnabled="true" logfilename="c:\log.txt" /&gt;
   &lt;/system.diagnostics&gt;
&lt;/configuration&gt;
Figure: Never set AssertUIEnabled="true" in web.config &lt;configuration&gt;
   &lt;system.diagnostics&gt;
      &lt;assert AssertUIEnabled="false" logfilename="c:\log.txt" /&gt;
   &lt;/system.diagnostics&gt;
&lt;/configuration&gt;
Figure: Should set AssertUIEnabled="false" in web.config

Acknowledgements

Adam Cogan
Ryan Tee
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star