This documentation is archived and is not being maintained.

VirtualPathExtension Class

Contains the service's virtual path when the service is hosted in Internet Information Services (IIS) or Windows Process Activation Service (WAS).

Namespace: System.ServiceModel.Activation
Assembly: System.ServiceModel (in system.servicemodel.dll)

public sealed class VirtualPathExtension : IExtension<ServiceHostBase>
public final class VirtualPathExtension implements IExtension<ServiceHostBase>
public final class VirtualPathExtension implements IExtension<ServiceHostBase>
Not applicable.

This extension is only present for services hosted in IIS or WAS. Services can determine whether they are hosted in IIS or WAS by retrieving this extension from their ServiceHostBase, as shown in the following example.

The following example shows how to recover the VirtualPathExtension from the service host and return a value that it is hosted in IIS or WAS.

bool isHosted = false;
ServiceHostBase host = OperationContext.Current.Host;
VirtualPathExtension vpe = host.Extentions.Find<VirtualPathExtension>();

if( vpe != null )
   isHosted = true;
Console.WriteLine("Is the service hosted in IIS or WAS? {0}", isHosted);


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0