Am I running a Web or Windows Application

  • Thread starter Thread starter muesliflakes
  • Start date Start date
M

muesliflakes

I would like to check from a generic library whether the currently
running application is a web application or a windows application.

if ( MyApp.IsWinApp )
{
// Do Win App code
}
if ( MyApp.IsWebApp )
{
// Do web app code
}

As a secondary issue, can I tell if the application is some other sort
of app, such as a windows service etc...

Cheers David
 
Why not pass a parameter into the constructor of the classes in this library specifying what type of application is using it

Rasika Wijayaratne
 
Thats a posibility of course, but then that is more work for the
programmer on what should be a very simple boolean switch.

That also does not help for supporting generic (Already inuse
components) that can easily be adapted from current environ (WinApp) to
(WebApp).

In the body of my component I just want to go.

Example (I've just typed this, it may not be real scenario)
string fileName;

if ( EnvironmentUtil.IsWebApp( ) )
{
fileName = AppDomain.CurrentDomain.BaseDirectory;
}
else
{
fileName = System.Environment.CurrentDirectory;
}
 
Back
Top