本文介绍了WCF服务的IIS。如何摆脱&QUOT的; Service.svc"在URL路径组成部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WCF服务托管在IIS 对于商务原因,我不能发布此实例的公开网址,但我敢肯定,你会明白我的意思:

I have a WCF Service hosted on IIS. For business reason I cannot post the public URL of this instance, but I'm sure you will get what I mean:

现在的问题是,为了达到我的终点看来我得包括 Service.svc 作为路径段的一部分,即,我必须使用的网址是这样的:

The problem is that in order to reach my endpoint it seems I have include the Service.svc as part of the path segment, i.e., I have to use URLs like this:

的http://&LT;域&GT; /&LT; APP-名称&gt; /Service.svc/<相对路径&GT;

我怎样才能避免这种我的意思是,我想用简单的访问我的服务:

How can I avoid this? I mean, I'd like to access my service simply with:

的http://&LT;域&GT; /&LT; APP-名称&gt; /&LT;相对路径&GT;

我是完全能够做到这一点,当我在开发过程中自托管的服务。

I was perfectly able to do this when I was self-hosting the service during development.

最后,但这不那么超然,浏览到的http://&LT;域&GT; /&LT; AppName的&GT; /Service.svc URL显示标准的服务信息页面:

Lastly, but this is not-so-transcendental, browsing to the http://<domain>/<AppName>/Service.svc URL displays the standard service information page:

有没有一种方法,我也从$被访问p $ pvent呢?

Is there a way I could also prevent this from being accessible?

推荐答案

第一部分:不要有网址的service.svc的一部分,你可以使用ASP.NET路由功能,和的级 - preFIX你的路线是空字符串。在邮政http://blogs.msdn.com/b/endpoint/archive/2010/01/25/using-routes-to-compose-wcf-webhttp-services.aspx说明了如何可以做到这一点。

First part: to not have the "service.svc" part of the URL, you can use the ASP.NET Routing feature, and the ServiceRoute class - the prefix for your route would be the empty string. The post at http://blogs.msdn.com/b/endpoint/archive/2010/01/25/using-routes-to-compose-wcf-webhttp-services.aspx shows how this can be done.

第二部分:以prevent,从被显示帮助页面中,您可以通过配置文件中禁用它(或通过使用自定义服务主机工厂code)。下面是它可以通过配置来完成:

Second part: to prevent that "help" page from being shown, you can disable it via config (or via code using a custom service host factory). Here's how it can be done via config:

<serviceBehaviors>
    <behavior>
        <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false"/>
    </behavior>
</serviceBehaviors>

的行为不具有name属性,这意味着它将被用作对服务的默认行为。

The behavior does not have the "name" attribute, which means that it will be used as the default behavior for services.

这篇关于WCF服务的IIS。如何摆脱&QUOT的; Service.svc&QUOT;在URL路径组成部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:27