Programmatically determining WinForm or ASP.NET

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
 
N

NuTcAsE

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
 
V

Vadym Stetsyak

if ASP.NET is hosted on the IIS, you can check process name from within your
class.
IIS has predefied process names
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top