Programmatically determining WinForm or ASP.NET

  • Thread starter Thread starter Larry Hunt
  • Start date Start date
L

Larry Hunt

I am developing a class which will be used in both a WinForm and ASP.NET 2.0
application. The class needs to know which type of application it is running
in. How do you programmatically determine what type of application (WinForm
or ASP.NET) you are currently running in? I have looked at
Environment.UserInteractive but this will not have the right effect when
debugging an ASP.NET application.

Thanks,
Larry
 
You can check the System.Web.HttpContext.Current property for null. If
the return is null then it is executing out of the ASP.Net pipeline, if
it returns a valid HttpContext class then its running from withing the
ASP.Net pipleline.

Hope this helps...
- NuTcAsE
 
if ASP.NET is hosted on the IIS, you can check process name from within your
class.
IIS has predefied process names
 
Back
Top