Thanks for DLM's input.
Hi rgliane,
I agree with DLM that you can use the "HttpContext.Current" property to
check whether the current application runtime is in ASP.NET web application
or not. For ASP.NET web application the HttpContext.Current represent the
HttpContext instance attached to the current workerthread. While for
non-ASP.NET application, this property is Null.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
[quoted text, click to view] >Reply-To: "dlm@bypsoft" <nospam.dlm@bypsoft.com>
>From: "dlm@bypsoft" <nospam.dlm@bypsoft.com>
>References: <812CA121-6A81-4F39-B6AC-557E17BDA88C@microsoft.com>
>Subject: Re: How do I check if class lib is being used by web or windows
app?
>Date: Fri, 29 Feb 2008 23:33:40 +0100
>
>Hi,
>the following code should give you answer if your Assembly is used in Web
or Win environment.
>using System;
>using System.Web;
>namespace ClassLibrary1
>{
>public class Class1
>{
>public Class1() { }
>public bool IsWebApp(){
>return (HttpContext.Current != null);
>}
>}
>}
>Hope this helps. Best regards,
>DLM@bypsoft
>Cross database solutions
>Compare databases for free - SQL Server, MySQL and Oracle
>"rgliane" <rgliane@newsgroup.nospam> schrieb im Newsbeitrag
news:812CA121-6A81-4F39-B6AC-557E17BDA88C@microsoft.com...
>> [Didn't get an official response from MS...so am reposting after setting
up
>> alias]
>>
>> I have a method in a common class library that reads the application
config
>> file. If the library is used by a Windows app, it should use
>> ConfigurationManager to read the app.config file. If the library is
used by
>> a Web app, it should use WebConfigurationManager to read the web.config
file.
>>
>>
>> Is there a programmatic way for the class lib to determine what kind of
app
>> is running? Or is there another approach to handle this kind of thing?
>>
>
Hi rgliane,
Do you have any further questions on this?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
[quoted text, click to view] >From: stcheng@online.microsoft.com ("Steven Cheng")
>Organization: Microsoft
>Date: Mon, 03 Mar 2008 01:33:22 GMT
>Subject: Re: How do I check if class lib is being used by web or windows
app?
[quoted text, click to view] >
>Thanks for DLM's input.
>
>Hi rgliane,
>
>I agree with DLM that you can use the "HttpContext.Current" property to
>check whether the current application runtime is in ASP.NET web
application
>or not. For ASP.NET web application the HttpContext.Current represent the
>HttpContext instance attached to the current workerthread. While for
>non-ASP.NET application, this property is Null.
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>--------------------
>>Reply-To: "dlm@bypsoft" <nospam.dlm@bypsoft.com>
>>From: "dlm@bypsoft" <nospam.dlm@bypsoft.com>
>>References: <812CA121-6A81-4F39-B6AC-557E17BDA88C@microsoft.com>
>>Subject: Re: How do I check if class lib is being used by web or windows
>app?
>>Date: Fri, 29 Feb 2008 23:33:40 +0100
>>
>>Hi,
>>the following code should give you answer if your Assembly is used in Web
>or Win environment.
>>using System;
>>using System.Web;
>>namespace ClassLibrary1
>>{
>>public class Class1
>>{
>>public Class1() { }
>>public bool IsWebApp(){
>>return (HttpContext.Current != null);
>>}
>>}
>>}
>>Hope this helps. Best regards,
>>DLM@bypsoft
>>Cross database solutions
>>Compare databases for free - SQL Server, MySQL and Oracle
>>"rgliane" <rgliane@newsgroup.nospam> schrieb im Newsbeitrag
>news:812CA121-6A81-4F39-B6AC-557E17BDA88C@microsoft.com...
>>> [Didn't get an official response from MS...so am reposting after
setting
>up
>>> alias]
>>>
>>> I have a method in a common class library that reads the application
>config
>>> file. If the library is used by a Windows app, it should use
>>> ConfigurationManager to read the app.config file. If the library is
>used by
>>> a Web app, it should use WebConfigurationManager to read the web.config
>file.
>>>
>>>
>>> Is there a programmatic way for the class lib to determine what kind of
>app
>>> is running? Or is there another approach to handle this kind of thing?
>>>
>>
>
>
Don't see what you're looking for? Try a search.