Detect if running from console

Topics: Core, Customizing Orchard, Writing modules
Apr 26, 2012 at 7:31 AM

How can I detect from within a service if it is in an orchard command line tool appdomain?

I need to disable certain functionality if it is.

May 3, 2012 at 2:06 PM


May 3, 2012 at 2:40 PM

You probably have to redesign your services that what has to be called only from withing a request is indeed only called from one. But I guess you could use IHttpContextAccessor, it should return an empty HttpContext, or its values should reflect that there is no request.

May 3, 2012 at 3:00 PM

Perhaps the HostingEnvironment class can give you some clues?