.net - Determine whether running in ASP.NET or WinForms/console without System.Web -


From the class library, I need to decide on run-time whether I am running in an asp.net application Or WinForms / Console apps are on this topic, but all those solutions have systems Need to add to the context of the web. If possible, when my console and Winform applications run, I do not want to load the system. Only in the line of one of the thousands of code in the web assembly Class = "post-text" itemprop = "text">

Use System.Diagnostics.Process.GetCurrentProcess (). Process name

If you are running ASP.NET, the name w3wp.exe is if you are running IIS 6.0 or IIS 7.0.

  • If you are,

    • To run the first version of IIS, the name of aspnet_wp.exe is named.

      Another idea: How to test the process / app domain for the presence of System.Web.dll AppDomain.CurrentDomain.GetAssemblies () with the API?

  • Comments