我有一个基于WCF的RESTful API(.NET Framework 4.0),在IIS 7.0(Win7)或IIS 6.0(Server 2003)上托管时工作正常。但是,我发现在IIS 5.1(Windows XP)上托管该网站存在一个问题,这是令人惊讶的,因为我认为5.1和6.0的区别仅在于托管网站的数量。
以下请求(the result screenshot)一切正常:
http://localhost/test/api/OrderService.svc
所以我想我不需要注册任何模块来处理SVC文件或任何其他模块。 但是,以下请求(the result screenshot):
http://localhost/test/api/OrderService.svc/rest/orders?format=json
返回HTTP代码404。 我已经检查了事件查看器但没有找到任何内容。
同样,一切都适用于IIS 7.0和IIS 6.0。 这是web.config文件(有些东西被剪掉):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<globalization uiCulture="auto" />
<customErrors mode="Off" />
</system.web>
<system.webServer>
<!--Это приложение определяет конфигурацию в разделе system.web/httpHandlers.
Если есть уверенность, что можно игнорировать эту ошибку, сообщение о ней можно отключить, установив для параметра system.webServer/validation@validateIntegratedModeConfiguration значение false.
Для запуска приложений ASP.NET на сервере IIS 7.0 и более поздних версий предпочтительным является интегрированный режим.-->
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<remove name="WebDAV" />
<add name="AddAsmx" verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="AppService" verb="*" path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="soapBinding" closeTimeout="00:02:00" hostNameComparisonMode="Exact" maxBufferSize="120000" maxReceivedMessageSize="120000" >
<security mode="Transport" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="restBinding">
<security mode="Transport" />
</binding>
<!--http://social.msdn.microsoft.com/Forums/en/wcf/thread/845d0bbd-52b4-420f-bf06-793d53ef93ba-->
<!--<binding name="poxBinding">
</binding>-->
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="XDDF" maxBufferSize="120000" maxReceivedMessageSize="120000" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
<services>
<service behaviorConfiguration="slBehavior" name="WcfServiceLibrary.OrderService">
<endpoint address="soap" binding="basicHttpBinding" name="basicHttpBinding" bindingConfiguration="soapBinding" contract="WcfServiceLibrary.IOrderService" />
<endpoint address="rest" binding="webHttpBinding" bindingConfiguration="restBinding" behaviorConfiguration="restBehavior" contract="WcfServiceLibrary.IOrderService" />
<!--<endpoint address="pox" binding="webHttpBinding" bindingConfiguration="poxBinding" behaviorConfiguration="poxBehavior" contract="WcfServiceLibrary.IOrderService"/>-->
<endpoint address="mex" binding="mexHttpsBinding" name="mexHttpbinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<!--<enableWebScript/>-->
<webHttp />
</behavior>
<!--<behavior name="poxBehavior">
<webHttp />
</behavior>-->
</endpointBehaviors>
<serviceBehaviors>
<behavior name="slBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="returnFaults" />
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
请帮忙。我找不到任何有用的东西。
答案 0 :(得分:3)
执行以下操作对我有用。
答案 1 :(得分:0)
我发布这个以便我可以帮助其他人,因为我有同样的问题,并且IIS 5上的WCF REST上的大多数帖子都是旧的。
您的应用程序池对该网站/虚拟目录的权限可能存在问题,您可以尝试设置该权限并尝试使用。
您可以参考此文章获取更多帮助。