This documentation is archived and is not being maintained.

WebServiceHost Class

A ServiceHost derived class that compliments the Windows Communication Foundation (WCF) Web programming model.

Namespace:  System.ServiceModel.Web
Assembly:  System.ServiceModel.Web (in System.ServiceModel.Web.dll)

public ref class WebServiceHost : public ServiceHost

If WebServiceHost finds no endpoints in the service description, it automatically creates a default endpoint at the service's base address for HTTP and HTTPS base addresses. It does not create an endpoint automatically if the user has configured an endpoint explicitly at the base address. WebServiceHost automatically configures the endpoint's binding to work with the associated Internet Information Services (IIS) security settings when used in a secure virtual directory.

When creating a default HTTP endpoint, the WebServiceHost also disables the HTTP Help page and the Web Services Description Language (WSDL) GET functionality so the metadata endpoint does not interfere with the default HTTP endpoint.

In addition, the WebServiceHost class adds the WebHttpBehavior to all endpoints that do not already have the behavior and that have a WebMessageEncodingElement. If all the operations on the service have either empty HTTP request bodies or deal with the HTTP request body as a stream, then the WebServiceHost automatically configures the appropriate content type mapper for the binding.

The following example shows how to use the WebServiceHost class to host a service that makes use of the WCF Web programming model.

No code example is currently available or this language may not be supported.

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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5