Search code examples
c#asp.netmanaged

How to differentiate whether a managed library is running in the context of asp.net application or in a executable?


how to differentiate whether a managed library is running in the context of asp.net application or in a executable?


Solution

  • You could check whether HttpContext.Current returns null or not.

    Technically, it'll also return null in an ASP.NET application if it's running on a non-worker thread (i.e. if you just go new Thread(SomeProc)) but it should work 99% of the time.