I am writing a class library and want to perform some conditional processing if the client/host application using the library is an ASP.NET application.
I am thinking that the simplest way of checking that would be simply to set a static reference to System.Web.dll
in my library and then to check if the HttpContext
object is null or not. If it is not null, then we know that we're running in the context of a Web app.
However, I am not sure if this is a fool-proof method. Is there a more sophisticated approach?