maxRequestLength 在没有机器配置更改的情况下无法工作

maxRequestLength not working without machine config change

这是我的配置文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="SharedFilePath" value="\share\DocumentFiles" />
  </appSettings>
  <system.web>
    <compilation targetFramework="4.6" />
    <httpRuntime maxRequestLength="32768" executionTimeout="14400" targetFramework="4.6" requestLengthDiskThreshold="32768" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="GeneralBasicHttpBinding" maxReceivedMessageSize="2147483647" closeTimeout="0:15:00" openTimeout="0:15:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="Streamed">
          <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="ServiceBehaviour" name="DocumentFiles.Service.Contract.Implementation.DocumentFilesImplementation">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="GeneralBasicHttpBinding" contract="DocumentFiles.Service.Contract.Operations.IDocumentFiles" />
        <!--<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>-->
      </service>
    </services>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="false" />
  </system.webServer>
</configuration>
<!--ProjectGuid: DD0CDEB9-DBFC-4ECA-837C-BAF09499A3FA-->

发布 5MB 的文件时会抛出错误:配置文件中指定的扩展名出现异常 运行。 ---> 超过最大请求长度。

但是当我更改默认网站(托管服务的地方)的配置以使用 maxRequestLength="32768" 时,文件发布正常。

还有什么我需要做的才能不让它只在更新机器配置的情况下工作吗?

不幸的是没有。 您必须更改 web.config 文件