Re: How to detect if my component is being called from ASP.NET application?

From: John Lee (johnl_at_newsgroup.nospam)
Date: 01/11/05


Date: Tue, 11 Jan 2005 15:55:20 -0800

I tried the following code -

if (System.Web.HttpContext.Current != null)
{
    //invoked by ASP.NET app

}
else
{
    //windows app
}

Is above solution 100% reliable?

Thanks!
John

"John Lee" <johnl@newsgroup.nospam> wrote in message
news:OOWOARD%23EHA.2196@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> I have a component with some static public methods and is it possible from
> inside my method to decide if my component is invoked by an ASP.NET
> application (such as web service) or a windows application? If YES, How to
> do that?
>
> If I know it's invoked by web service (web service is configured as
> windows authentication only and assigned an application pool with NT
> domain account as identity), Is the following assumption is 100% correct?
> or what is the most reliable way of getting the authenticated user's name
> and the service account's name?
>
> 1. Authenticated user will be
> System.Threading.Thread.CurrentPrincipal.Identity.Name
> 2. Service account will be WindowsIdentity.GetCurrent().Name
>
> If it's invoked by windows app, the authenticated user will be
> WindowsIdentity.GetCurrent().Name, is this valid and reliable assumption?
>
> Thanks a lot!
> John
>
>



Relevant Pages

  • How to detect if my component is being called from ASP.NET application?
    ... I have a component with some static public methods and is it possible from ... If I know it's invoked by web service (web service is configured as windows ... If it's invoked by windows app, the authenticated user will be ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to detect if my component is being called from ASP.NET application?
    ... IIRC HttpContext.Currrent returns null if you are not hosted under ASP.NET but a valid context if you are. ... If I know it's invoked by web service (web service is configured as windows ... If it's invoked by windows app, the authenticated user will be ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ADFS Development Issues
    ... One thing to keep in mind is that if a website is protected by ADFS V1, ... site to be automatically authenticated by our windows application so ... like a web service proxy. ... generated on the server. ...
    (microsoft.public.windows.server.active_directory)
  • Re: ADFS Development Issues
    ... site to be automatically authenticated by our windows application so ... based on redirects and possibly uses forms-based authentication to collect ... web service proxies don't handle this type of thing ... the server based on how it needs to work. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Dynamically Change URL of web service
    ... Microsoft MVP - Windows Client ... > client apps will use the exact same web service, ... What this does is put an entry in the config file, ... >>> How can I dynamically change this when the client app loads. ...
    (microsoft.public.dotnet.framework.windowsforms)