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

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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 );
 
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.
 
// Get the current process.
Process currentProcess = Process.GetCurrentProcess();
 
Back
Top