I have an instance of a general purpose class that will be executed both under ASP.NET and a stand alone program. This code is sensative to the process where it is being run
This is my answer to the question.
First, make sure your project references System.Web and that your code file is "using System.Web;".
public class SomeClass {
public bool RunningUnderAspNet { get; private set; }
public SomeClass()
//
// constructor
//
{
try {
RunningUnderAspNet = null != HttpContext.Current;
}
catch {
RunningUnderAspNet = false;
}
}
}