Pergunta

I have read through what seems to be available on the internet for replacing the standard WCF landing page with a custom site, however, these solutions seem not to apply to IIS hosting. Both this question and this walkthrough suggest creating an unmatched message handler and disabling metadata publishing. However, the comments for both suggest that it doesnt work when hosted in IIS and I can confirm this appears to be the case.

Is there a step missing that IIS requires? Something that needs configured on the server for this to work? Any help would be great. This is a .NET 4.5 WCF SOAP service.

Foi útil?

Solução

In IIS hosted WCF service the ServiceHost is created by w3wp for you (as against selfhost where you create it). A ServiceDebug behavior is added by default in this ServiceHost which results in this not working. Starting WCF 4.5 you can easily configure your IIS hosted service in code. Add this piece of code to your service implementation.

public class Service1 : IService1, ILandingPage
    {
...
...

public static void Configure(ServiceConfiguration serviceConfig)
        {
            //Still continue to load the service configuration from your web.config file as before.
            serviceConfig.LoadFromConfiguration();
            //Remove the serviceDebug behavior. 
            serviceConfig.Description.Behaviors.Remove<ServiceDebugBehavior>();
        }
}

For more details on configuring IIS hosted service in code refer to this. If you are using .net framework version < 4.5 you can achieve the same by implementing a custom service host factory and do all the service configuration yourself in code.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top