在IIS 7.5中托管时自定义WCF登录页面 [英] Custom WCF Landing Page when Hosted in IIS 7.5

查看:222
本文介绍了在IIS 7.5中托管时自定义WCF登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了互联网上似乎可以用自定义网站替换标准WCF登录页面的内容,但是,这些解决方案似乎不适用于IIS托管。 这个问题本演练建议创建一个不匹配的消息处理程序并禁用元数据发布。但是,两者的评论都表明它在IIS中托管时不起作用,我可以确认这似乎是这种情况。

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.

IIS需要缺少一个步骤吗?需要在服务器上配置以使其工作的东西?任何帮助都会很棒。这是一个.NET 4.5 WCF SOAP服务。

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.

推荐答案

在IIS托管的WCF服务中,由w3wp为您创建ServiceHost(如反对你创建它的selfhost)。默认情况下,此ServiceHost中添加了ServiceDebug行为,导致此行为无效。启动WCF 4.5,您可以在代码中轻松配置IIS托管服务。将这段代码添加到您的服务实现中。

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>();
        }
}

有关在代码中配置IIS托管服务的详细信息,请参阅这个。如果您使用.net框架版本< 4.5您可以通过实现自定义服务主机工厂来实现相同的功能,并在代码中自行完成所有服务配置。

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.

这篇关于在IIS 7.5中托管时自定义WCF登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆