From a managed class library, I\'d like to find out whether the currently executing application is an ASP.NET web application (web forms or MVC) or not.
I have seen diff
This might be helpful:
How can I detect if my .NET assembly is running from web site or from a desktop machine?
if(HttpRuntime.AppDomainAppId != null) { //is web app } else { //is windows app }