This documentation is archived and is not being maintained.


This element defines the type the service hosting environment instantiates for a particular transport. If this element is empty, the default type is used.



									<serviceHostingEnvironment aspNetCompatibilityEnabled="Boolean">
									        <transportConfigurationType name="String" 
									              transportConfigurationType="String" />

The following sections describe attributes, child elements, and parent elements.


Attribute Description


A Boolean value indicating whether the ASP.NET compatibility mode has been turned on for the current application. The default is false.

When this attribute is set to true, requests to WCF services flow through the ASP.NET HTTP pipeline, and communication over non-HTTP protocols is prohibited.

Child Elements

Element Description


A collection of transportConfigurationType elements.

Parent Elements

Element Description


The root element of all Windows Communication Foundation (WCF) configuration elements.

By default, WCF services run side-by-side with ASP.NET in hosted Application Domains (AppDomain). Even though WCF and ASP.NET can coexist in the same AppDomain, WCF requests are not processed by the ASP.NET HTTP Pipeline by default. As a result, several elements of the ASP.NET application platform are not available to WCF services. These include

  • ASP.NET File/URL Authorization

  • ASP.NET Impersonation

  • Cookie-based Session State

  • HttpContext.Current

  • Pipeline Extensibility via custom HttpModule

If your WCF services need to function in the ASP.NET context, and communicate only over HTTP, you can use WCF’s ASP.NET compatibility mode. This mode is turned on when the aspNetCompatibilityEnabled attribute is set to true at the application level. Service implementations must declare their ability to run in compatibility mode using the AspNetCompatibilityRequirementsAttribute class. When the compatibility mode is enabled,

  • ASP.NET File/URL Authorization is enforced prior to WCF authorization. An authorization decision is based on the transport-level identity of the request. Identities at the message level are ignored.

  • WCF service operations start to execute in the ASP.NET impersonation context. If both ASP.NET impersonation and WCF impersonation are enabled for a specific service, the WCF impersonation context applies.

  • HttpContext.Current can be used from WCF service code, and services are prevented from exposing non-HTTP endpoints.

  • WCF requests are processed by the ASP.NET pipeline. HttpModules that have been configured to act on incoming requests can also process WCF requests. These can include ASP.NET platform components (e.g., SessionStateModule), as well as custom third party modules.

The following code sample shows how to enable ASP Compatibility Mode.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
Footer image

Send comments about this topic to Microsoft.
© Microsoft Corporation. All rights reserved.