![](/img/trans.png)
[英]Cannot run ASP.net service on IIS (Windows 10) - error 404 (not found)
[英]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 5上的WCF REST上的大多數帖子都是舊的。
對於該網站/虛擬目錄,您的應用程序池的權限可能存在問題,您可以嘗試設置該權限並進行嘗試。
您可以參考這篇文章以獲得更多幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.