WCF services running in mixed transports mode (aspNetCompatibilityEnabled="false")

WCF services running in mixed transports mode (aspNetCompatibilityEnabled="false")

 
One of the features of WCF service is an ability to run it in the mixed transports mode.

“In this mode, WCF services do not have ASP.NET HTTP-specific features. Instead, all transports are treated in the same way. A WCF service can have multiple endpoints and they can listen on the same or different transports such as HTTP, net.tcp, net.pipe, or net.msmq.

"The disabled ASP.NET HTTP features are:

HttpContext.Current: This is always null in this mode. For ASMX services, this is a ThreadStatic property that is stored in the Thread Local Store (TLS). WCF provides a counterpart to this feature: OperationContext.Current.

File/Url Authorization: This transport layer authorization feature is normally enabled through the <system.web/authorization> section in web.config for ASMX sevices. It is disabled in the mixed mode in WCF. You need to use message-level authorization implemented in WCF.

Impersonation: The ASP.NET impersonation feature is normally enabled through the <system.web/identity> section in web.config for ASMX services. It is not available in WCF transport layer in the mixed mode.

Session state: The ASP.NET session state is not supported in the mixed mode. WCF has its own reliable session implementation which provides flexible session state management. The biggest problem for WCF V1 is that the session state does not survive on application recycling and does not work in web garden/farm cases because there is not shared state mechanism between applications or processes which, however, are supported by ASP.NET state service.

Other HTTP features: There are other HTTP features which rely on HttpContext.Current are not supported in the mixed mode naturally. For example, you can not expect that you can get the correct result from ConfigurationManager.AppSettings to work. The globalization feature through <system.web/globalization> is not available.”

As you can see the mode has some limitations. But we can provide solution for this case. SSRS Viewer is completely capable in this mode (starting from version 3.1):

  1. First of all you need to set aspNetCompatibilityEnabled="false" in the web.config file.
  2. Then, download the source code files attached to this article and add them to your project: SerializationSurrogates folder and FolderCache
  3. Reload some methods of the service to make our FolderCache to be used:

 

 

namespace SampleApplicationSL4.Web

{

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    public class ReportService : ReportServiceRemote

    {

        private FolderCache _cache = new FolderCache(@"C:\Temp\Cache\");

               

        protected override IReportCache CreateCache()

        {

            return _cache;

        }

 

        protected override ExceptionDetailBase HandleError(System.Exception e)

        {

            return base.HandleError(e);

        }

 

        protected override PerpetuumSoft.ReportingServices.Viewer.Server.Storage.ParametersStorage CreateParametersStorage()

        {

            return _cache;

        }

 

        protected override string GetServiceUrl()

        {

            return base.GetServiceUrl();

        }

    }

}

 

After completing these steps, reportViewer is completely ready for work.

Add Feedback