How do I make a class library that works in ASP.NET and non-ASP.NET applications?
<p>I want to write a class library that works in ASP.NET and standalone applications. Some differences in behavior are needed when running under ASP.NET. What is the recommended way to check if the library is running in an ASP.NET application?</p>

<p>I can check <code>HttpContext.Current</code>, as it appears to reliably return null when not running under ASP.NET. However, when running on a background thread in ASP.NET, it also returns null.</p>

<p>Any opinions on <code>HttpContext.Current</code> or other solutions?</p>

<p>ADDED: Thanks for all the advice on how to achieve a separation of concerns. However, I would like to add that this library will not be for general-purpose use, so for my particular case I do not need a lot of flexibility. In my mind, the best so far (not mentioned in this thread) is to check the  <code>HttpRuntime.AppDomainAppId</code> static for null as it seems to work okay even for ASP.NET background threads. However, the various solutions contributed here will surely be helpful to others with more general needs.</p>
