The HttpContext.IsDebuggingEnabled property:
using System.Web;
if (HttpContext.Current.IsDebuggingEnabled) { /* ... */ }
From the documentation:
Gets a value indicating whether the current HTTP request is in debug mode[…]
trueif the request is in debug mode; otherwise,false.