2011-08-16 209 views
36

在VS 2008中,我可以運行.svc但生產IIS 7我不能。我得到這個錯誤。我正在使用x64獲勝。HTTP錯誤404.17 - 未找到

我跑

C:\Windows\Microsoft.NET\Framework\v2.5.0.30319>aspnet_regiis.exe -i 
Start installing ASP.NET (4.0.30319). 
......................... 

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i 
The error indicates that IIS is not installed on the machine. Please install IIS 
Finished installing ASP.NET (2.0.50727). 

卻是相同的。我運行VS 2008.應用程序池:NET framweork是2.0。我使32位應用程序

Error Summary 
HTTP Error 404.17 - Not Found 
The requested content appears to be script and will not be served by the static file handler. 
Detailed Error Information 
Module StaticFileModule 
Notification ExecuteRequestHandler 
Handler StaticFile 
Error Code 0x80070032 
Requested URL http://192.168.2.4:80/Service.svc 
Physical Path C:\inetpub\wwwroot\WebServices\Service.svc 
Logon Method Anonymous 
Logon User Anonymous 
Most likely causes: 

    The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler. 

Things you can try: 

    If you want to serve this content as a static file, add an explicit MIME map. 

編輯:

的web.config

<?xml version="1.0"?> 

<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use 
    the Website->Asp.Net Configuration option in Visual Studio. 
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
--> 
<configuration> 
    <configSections> 
     <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> 
     <section name="nhibernateSettings" type="ProjectBase.Data.NHibernateSessionMgmt.OpenSessionInViewSection, ProjectBase.Data" /> 
     <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
       <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
       <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
        <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /> 
        <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
        <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
       </sectionGroup> 
      </sectionGroup> 
     </sectionGroup> 
    </configSections> 
    <appSettings> 
     <add key="NHibernateConfigPath" value="D:\PROJEKTI\WebServices\DotNet\WebServices\WebServices\NHibernate.config" /> 
    </appSettings> 
    <connectionStrings> 
     <add name="connectionString" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=WebServices;Data Source=.\SQL2008" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <nhibernateSettings> 
     <!-- List every session factory that will be needed; transaction management and closing sessions 
      will be managed with the open-session-in-view module --> 
     <sessionFactories> 
      <clearFactories /> 
      <sessionFactory name="WebCrawlerFactory" factoryConfigPath="D:\PROJEKTI\WebServices\DotNet\WebServices\WebServices\NHibernate.config" isTransactional="true" /> 
     </sessionFactories> 
    </nhibernateSettings> 
    <log4net> 
     <appender name="LogAllToFile" type="log4net.Appender.FileAppender"> 
      <file value="WebCrawler.log" /> 
      <appendToFile value="false" /> 
      <layout type="log4net.Layout.PatternLayout"> 
       <conversionPattern value="%d [%t] %-5l - %m%n%n" /> 
      </layout> 
     </appender> 
     <root> 
      <priority value="ALL" /> 
      <!-- ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF--> 
      <appender-ref ref="LogAllToFile" /> 
     </root> 
    </log4net> 
    <system.web> 
     <!-- 
      Set compilation debug="true" to insert debugging 
      symbols into the compiled page. Because this 
      affects performance, set this value to true only 
      during development. 
     --> 
     <compilation debug="true"> 
      <assemblies> 
       <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
       <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      </assemblies> 
     </compilation> 
     <!-- 
      The <authentication> section enables configuration 
      of the security authentication mode used by 
      ASP.NET to identify an incoming user. 
     --> 
     <authentication mode="Windows" /> 
     <!-- 
      The <customErrors> section enables configuration 
      of what to do if/when an unhandled error occurs 
      during the execution of a request. Specifically, 
      it enables developers to configure html error pages 
      to be displayed in place of a error stack trace. 

     <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> 
      <error statusCode="403" redirect="NoAccess.htm" /> 
      <error statusCode="404" redirect="FileNotFound.htm" /> 
     </customErrors> 
     --> 
     <pages> 
      <controls> 
       <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      </controls> 
     </pages> 
     <httpHandlers> 
      <remove verb="*" path="*.asmx" /> 
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> 
     </httpHandlers> 
     <httpModules> 
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </httpModules> 
    </system.web> 
    <system.codedom> 
     <compilers> 
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
       <providerOption name="CompilerVersion" value="v3.5" /> 
       <providerOption name="WarnAsError" value="false" /> 
      </compiler> 
     </compilers> 
    </system.codedom> 
    <system.web.extensions> 
     <scripting> 
      <webServices> 
       <!-- 
       Uncomment this section to enable the authentication service. Include 
       requireSSL="true" if appropriate. 

      <authenticationService enabled="true" requireSSL = "true|false"/> 
      --> 
       <!-- 
       Uncomment these lines to enable the profile service, and to choose the 
       profile properties that can be retrieved and modified in ASP.NET AJAX 
       applications. 

      <profileService enabled="true" 
          readAccessProperties="propertyname1,propertyname2" 
          writeAccessProperties="propertyname1,propertyname2" /> 
      --> 
       <!-- 
       Uncomment this section to enable the role service. 

      <roleService enabled="true"/> 
      --> 
      </webServices> 
      <!-- 
     <scriptResourceHandler enableCompression="true" enableCaching="true" /> 
     --> 
     </scripting> 
    </system.web.extensions> 
    <!-- 
     The system.webServer section is required for running ASP.NET AJAX under Internet 
     Information Services 7.0. It is not necessary for previous version of IIS. 
    --> 
    <system.webServer> 
     <validation validateIntegratedModeConfiguration="false" /> 
     <modules> 
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </modules> 
     <handlers> 
      <remove name="WebServiceHandlerFactory-Integrated" /> 
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      <add name="ScriptResource" preCondition="integratedMode" 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> 
     <services> 
      <service name="WebServices.Service" behaviorConfiguration="WebServices.ServiceBehavior"> 
       <!-- Service Endpoints --> 
       <endpoint address="" binding="wsHttpBinding" contract="WebServices.IService"> 
        <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
        <identity> 
         <dns value="localhost" /> 
        </identity> 
       </endpoint> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="WebServices.ServiceBehavior"> 
        <!-- 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> 
     </behaviors> 
    </system.serviceModel> 
</configuration> 

回答

45

我receievd類似的錯誤:

HTTP Error 404.17 - Not Found 
The requested content appears to be script and will not be served by the static file handler. 

我試了幾臺機器相同的代碼。通過一些R & D,我終於發現原因可能是WCF映射沒有在IIS中註冊。

爲了解決上述錯誤:

  1. 導航到 「C:\ WINDOWS \ Microsoft.NET \框架\ 3.0 \的Windows 通信基礎」,在Visual Studio的命令提示符下
  2. 執行「 servicemodelreg -i「手動安裝映射
1

There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined

要麼你有<scriptResourceHandler> 2個節點在你的web.config,或您的.svc文件有自己的web.config,並且在同一個IIS應用程序中還有另一個web.config,它定義了<scriptResourceHandler>。如果這應該是一個嵌套在另一個ASP.NET站點下的獨立站點,則需要通過IIS管理工具將其創建爲應用程序,但不知道您的站點/應用程序的結構如何,我不能提供更多幫助。

+0

我沒有2 scriptResourceHandler也不是2 web.config – senzacionale

2

WCF映射未向IIS註冊。

導航到C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation和執行servicemodelreg -i安裝它們手動

+3

接受的答案的重複答案,但與有用的信息較少。 –

75

enter image description here問題是通過使Windows通訊基礎解決 - > HttpActivation Windows功能。

+4

由於某種原因必須同時執行3.5和4.5激活。謝謝! – kampsj

+3

最後!重新安裝10億次後,運行所有的reg解決方案(aspnet_regiis和servicemodelreg)......終於找到了問題。在Windows 8中,它在Windows功能 - > .NET Framework 4.5高級服務 - > WCF服務 - > HTTP激活非常感謝! – Nullius

+0

+ 1 ..也爲我工作。謝謝..!! –

1

對於Win7的機器,同樣的設置可以Conrol面板下進行 - >程序和功能 - >打開Windows功能打開或關閉

enter image description here

0

剛剛與一個BizTalk WCF服務爭奪部署在Windows Server 2012 IIS上。在測試了其他所有東西之後,還有其他一些想法,應用程序池。如果應用程序池設置爲經典模式,則需要將httpHandlers置於「控制」下,需要針對您打算使用的所有文件類型定義它們。如果你在集成模式下運行應用程序,IIS會照顧到這一點。對於在Google搜索後發現自己在這裏的人可能會有好處。:)

-1

我不得不爲svc NET 4.0手動添加處理程序映射。不知何故,它們已從IIS映射列表中消失。

我明白了HERE