繁体   English   中英

在IIS 5.1(Windows XP)问题404上托管.NET 4.0 REST WCF服务(无法找到资源)

[英]Hosting .NET 4.0 REST WCF service on IIS 5.1 (Windows XP) issue 404 (The resource cannot be found)

我有一个基于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的区别仅在于托管网站的数量。

以下请求( 结果屏幕截图 )一切正常:

http://localhost/test/api/OrderService.svc

所以我想我不需要注册任何模块来处理SVC文件或任何其他模块。 但是,以下请求( 结果截图 ):

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>

请帮忙。 我找不到任何有用的东西。

做以下工作对我有用。

  • 在IIS上选择应用程序的属性。
  • 在Virtual Directory选项卡中选择Configuration。
  • 单击添加。 选择Executable as aspnet_isapi.dll。 (通常这样的路径类似于
    C:\\ WINDOWS \\ microsoft.net \\框架\\ v4.0.30319 \\ ASPNET_ISAPI.DLL)。
  • 扩展为。*
  • 取消选中“检查该文件是否存在”。
  • 单击确定。

我发布这个以便我可以帮助其他人,因为我有同样的问题,并且在IIS 5上的WCF REST上的大多数帖子都是旧的。

对于该网站/虚拟目录,您的应用程序池的权限可能存在问题,您可以尝试设置该权限并进行尝试。

您可以参考这篇文章以获得更多帮助。

http://technicalwizardry.blogspot.in/2013/04/wcf-rest-service-hosted-on-iis-5.html#!/2013/04/wcf-rest-service-hosted-on-iis-5。 HTML

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM