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;
}
 

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

Back
Top