|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I tell if I'm in Console or Web application?Hi,
How do I tell from within code whether or not I'm in a web or console application? I need to know because it determines which config file I am going to access. There has to be a way via AppDomain or Environment, but I'm just not finding it. Thanks Try this:
if ( null == System.Web.HttpContext.Current ) // Add a reference to System.Web.dll { //Non Web Environment } else { //Web Environment } It may be fudgy on the first page you load. (Aka, when testing, you set a start up page to something like "default.aspx". I'm not 100% sure this is the case, I'm just suggesting to be aware of it. Show quote "Mowie_X" <merodg***@gmail.com> wrote in message news:1142865330.123713.322400@i40g2000cwc.googlegroups.com... > Hi, > > How do I tell from within code whether or not I'm in a web or console > application? I need to know because it determines which config file I > am going to access. > > There has to be a way via AppDomain or Environment, but I'm just not > finding it. > > Thanks > |
|||||||||||||||||||||||