所以我创建了一个 WCF 服务应用程序并将其托管在 IIS7 上。它目前有一些测试“helloworld”方法。当我在浏览器中运行它时,我得到这个屏幕:
现在服务本身运行良好,但我怎样才能显示这样的操作:
感谢 marc_s 提供的链接:http ://www.dotnetcurry.com/ShowArticle.aspx?ID=399我遵循了,所以我的网络配置现在设置如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfServer.Service1">
<endpoint address="" binding="webHttpBinding" contract="WcfServer.IService1" behaviorConfiguration="HelpBehaviour" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="HelpBehaviour">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" />
</system.webServer>
</configuration>
但是,这只适用于本地。当我在 IIS7 上发布到服务器时,单击帮助链接时出现 404 错误页面。有谁知道这是为什么,或者以前遇到过?
(最后一点是通过运行解决的aspnet_regiis.exe -iru
:)