c# RESTful Webservice - 自 web.config 更改后出现错误 404

c# RESTful Webservice - Error 404 since change of web.config

我正在使用 C# 使用 .NET 开发 Web 服务。一切正常,但由于我更改了我的 web.config 文件,我从服务器报告 404 返回错误 - 找不到文件。 异常发生在服务的构造函数完成之后和调用服务操作之前。 如果我从 web.config 中删除服务部分,它将再次工作。我需要允许更大的消息大小,因为我想进行一些文件传输并且不想将文件(主要是 1 到 150MB 之间的 zip)拆分为小于 30kb 的小块以使其工作。所以我需要提高允许的响应大小。 我不知道服务崩溃的原因,但我确定我的 web.config 有问题:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add
      name="MyDSNName"
      connectionString="MyConnectString"
  />
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <!--
      LogLevel DefaultValue: E_ALL, ^E_NOTE, ^E_HINT, ^E_INFO, ^E_TRACE
      Represents: E_ALL, without E_NOTE, E_HINT, E_INFO and E_TRACE

      Avaiable:                  E_ERROR, E_WARNING, E_DEBUG, E_TRACE, 
                                 E_HINT, E_INFO, E_NOTE, E_SYSTEM, E_BOOT, E_ALL

      Development Value:          E_ALL, ^E_HINT, ^E_INFO
      Production Value:           E_SYSTEM, E_ERROR, E_WARNING, E_HINT
    -->
    <add key="loglevel" value="E_ALL"/>
  </appSettings>
  <system.web>
    <compilation debug="true" optimizeCompilations="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="2147483647" 
          maxQueryStringLength="2097151"/>
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="UpdateServiceCfg" receiveTimeout="00:10:00" 
           sendTimeout="00:10:00" openTimeout="00:10:00" 
          closeTimeout="00:10:00" maxReceivedMessageSize="10485760" 
          transferMode="Streamed">
          <security mode="None"/>
          <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" 
           maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" 
           maxDepth="2147483647" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="UpdateServiceBehavior" name="MyApp.UpdateService">
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
          bindingConfiguration="UpdateServiceCfg" contract="MyApp.IUpdateService" />
        <host>
          <timeouts closeTimeout="00:10:00" />
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp helpEnabled="false" faultExceptionEnabled="true" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="UpdateServiceBehavior">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
             multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

谁能给我一个解决问题的提示?

提前致谢。

将 webHttpBinding 标记重命名为 basicHttpBinding 使其工作。 :)