Hi Xenophon,
How are you doing on this question? Does our suggestions help you a little?
If there're anything unclear or need any further assistance, please feel
free to post here. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 97818272
| References: <rs************ *************** *****@4ax.com>
<u2************ **@TK2MSFTNGP12 .phx.gbl>
<e$************ **@TK2MSFTNGP09 .phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From:
st*****@online. microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Thu, 10 Nov 2005 03:51:18 GMT
| Subject: Re: Best Way to Know Code is in ASP.NET?
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| Message-ID: <rE************ **@TK2MSFTNGXA0 2.phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Lines: 87
| Path: TK2MSFTNGXA02.p hx.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3569 11
| NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182
|
| Hi Xenophon,
|
| As Alvin has mentioend, using HttpContext.Cur rent may not be 100%
| accurate, however, if your class component is only used in asp.net
| application during the request's serverside pipeline, that should be ok.
| In addition, there're also some other means such as use the current
| executing process's ProcessName( asp.net worker process should always be
| aspnet_wp or w3wp...)
|
| Also, since asp.net web application's configuration file is always
| web.config, this is also a possbile approach to check(though not 100%
| accurate either...) , e.g:
|
| Response.Write( "<br/>" +
| AppDomain.Curre ntDomain.SetupI nformation.Conf igurationFile);
|
| Hope also helps.Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure!
www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
| --------------------
| | From: "Alvin Bruney - ASP.NET MVP" <www.lulu.com/owc>
| | References: <rs************ *************** *****@4ax.com>
| <u2************ **@TK2MSFTNGP12 .phx.gbl>
| | Subject: Re: Best Way to Know Code is in ASP.NET?
| | Date: Wed, 9 Nov 2005 15:23:42 -0500
| | Lines: 52
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.326
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.326
| | Message-ID: <e$************ **@TK2MSFTNGP09 .phx.gbl>
| | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | NNTP-Posting-Host: 71.174.110-65.q9.net 65.110.174.71
| | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| | Xref: TK2MSFTNGXA02.p hx.gbl
| microsoft.publi c.dotnet.framew ork.aspnet:3567 86
| | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| |
| | > Check static property System.Web.Http Context.Current . If it is null,
you
| | are
| | > not in Asp.Net.
| |
| | hmmm, that's risky.
| |
| | Context.Current evaluating to null only means that there is no current
| | context. There may well have been a context object a few milliseconds
| | before, or during page processing, but after the page is processed and
| sent
| | to the client the current context will not be available anymore. In this
| | case, it most definitely does not mean that the page is not running as
a
| web
| | application.
| |
| | > > I have a class that is used in an ASP.NET app, a WinForms app, and a
| | > > Win32 Service. What is the best way to tell what environment the
code
| | > > is currently instanced in?
| | An alternative approach would be to amend the class construct to take an
| | identifier indicating who is making the call.
| |
| | --
| | Regards,
| | Alvin Bruney [MVP ASP.NET]
| |
| | [Shameless Author plug]
| | The Microsoft Office Web Components Black Book with .NET
| | Now Available @
www.lulu.com/owc
| | Forth-coming VSTO.NET - Wrox/Wiley 2006
| | -------------------------------------------------------
| |
| |
| |
| | "Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
| | news:u2******** ******@TK2MSFTN GP12.phx.gbl...
| | > Check static property System.Web.Http Context.Current . If it is null,
you
| | are
| | > not in Asp.Net.
| | >
| | > Eliyahu
| | >
| | > "xenophon" <xe******@onlin e.nospam> wrote in message
| | > news:rs******** *************** *********@4ax.c om...
| | > >
| | > > I have a class that is used in an ASP.NET app, a WinForms app, and a
| | > > Win32 Service. What is the best way to tell what environment the
code
| | > > is currently instanced in?
| | > >
| | > > Thanks.
| | > >
| | >
| | >
| |
| |
| |
|
|