How to know whether my business object is called by web or windows

G

Guest

I have a business object which can be called by Windows or Web applications.
If this BO is called by Windows application, I need to use
ConfigurationManager to get config data. If this BO is called by web
application, I need to use WebConfigurationManager to get config data.

Can anybody tell me how I can know whether my business object is called by a
Windows client or Web client at the run time?

Thanks a lot.
 
V

Vadym Stetsyak

What is BusinessObject in your context. Simple class?

The fastest way to determine where BO "is living" is to check process name,
of the host application.

You can write small class that will get the settings of the IIS ( this will
be needed for web ).
the code will look as following
if (processName == "inetinfo.exe" ||
processName == "aspnet_wp.exe" ||
processName == "w3wp.exe" )
return ( webProcess );
else
return ( windowsProcess );
 
G

Guest

How do you get ProcessName? I tried to get it from a
System.Diagnostics.Process object. But when I run this code in my Windows
code, I got error message saying "No process is associated with this object."

Thanks.
 
V

Vadym Stetsyak

// Get the current process.
Process currentProcess = Process.GetCurrentProcess();
 

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