如何使用我自己的内容更改 wcf 服务的 html 输出? [英] How can I change an html output of wcf service with my own content?

查看:15
本文介绍了如何使用我自己的内容更改 wcf 服务的 html 输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 wcf 服务,它使用带有一些 url 的 BasicHttpBinding 和一个使用此服务的客户端.用户应启动客户端应用程序并指定在服务器端点中指定的相同 URL.

I wrote a wcf service that uses BasicHttpBinding with some url and a client using this service. Users should launch a client application and specify the same url that is specified in server endpoint.

然而,如果用户不小心在网络浏览器中打开了这个 url,他/她会看到有关如何检索服务元数据的信息,这对他们来说是绝对无用的.

However, if a user inadvertently opens this url in a web browser, he/she sees information on how to retrieve service metadata, which is absolutely useless to them.

应该怎么做才能让他/她看到,例如帮助主题?

What should be done in order for him/her to see, for example a help topic?

推荐答案

您需要关闭服务元数据的发布.

You need to turn off the publication of the service's metadata.

您可以在 Web.config 中禁用它:

You can disable it in the Web.config:

<serviceMetadata httpGetEnabled="false" />

您可以在此处找到有关 MSDN 的更多信息:

You can find more information on MSDN here:

http://msdn.microsoft.com/en-us/library/ms731317.aspx

当然,如果用户在地址栏中手动输入服务的 URL(例如:http://www.examle.com/service.svc).但是现在它会提到元数据当前已禁用.

Of course this will still generate a default landing page if a user manually enters the service's URL in the address bar (e.g.: http://www.examle.com/service.svc). However now it will mention that the metadata is currently disabled.

如果您想自定义该页面,我建议您查看以下线程,其中包含有关如何设置的完整代码示例:

If you want to customize that page I'd suggest you check out the following thread, it contains a complete code sample on how to set it up:

http:///social.msdn.microsoft.com/forums/en-US/wcf/thread/5778651a-b212-438a-b3e8-f7029775d52a/

这篇关于如何使用我自己的内容更改 wcf 服务的 html 输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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