看起来这个问题已被问过千次,但每个人的配置问题都不同。我有WCF服务器,它提供图像并接收上传图像请求。上传图片时,当大小超过65k时,我收到错误400.
我在WCF上打开了跟踪,我收到了确切的错误
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
我知道我需要增加这些参数,但我只能找到它应该在我的web.config文件中的位置。这是我在web.config中的内容:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Streamed">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ESLMobileIhaServiceClient.ServiceMobileIha" behaviorConfiguration="returnFaults">
<endpoint contract="ESLMobileIhaServiceClient.ServiceMobileIha" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex">
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
这里的任何人都可以帮我解决这个问题吗? ;)尝试4小时后在stackoverflow上找到不同的方法,但没有任何帮助 - 不幸的是。
更新
请求是从客户端到服务器上传文件。启用诊断时,错误将显示在服务器日志文件中。
SERVER Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Streamed">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ESLMobileIhaServiceClient.ServiceMobileIha" behaviorConfiguration="returnFaults">
<endpoint contract="ESLMobileIhaServiceClient.ServiceMobileIha" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex">
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
客户端App.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="InputFileLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\Stammdaten\"/>
<add key="OutputFileLocationOpen" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\offen\"/>
<add key="OutputFileLocationClosed" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\abgeschlossen\"/>
<add key="ImageObserveLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\kamerabilder\"/>
<add key="ImageSaveLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\savedimages\"/>
<add key="DeleteImageAfterCopy" value="true"/>
<add key="HelpFile_de_DE" value="ESL_EVU_1031_Mobile_Instandhaltung.pdf"/>
<add key="HelpFile_fr_FR" value=""/>
<add key="BackupLocation" value="backup\"/>
<add key="NumOfBackups" value="3"/>
<add key="Language" value="de_DE"/>
<add key="FontType" value="Arial"/>
<add key="TextSize" value="10"/>
<add key="TitleTextSize" value="12"/>
<add key="ButtonTextSize" value="12"/>
<add key="IdentifikationGeraet" value="Kontrolle/Instandhaltung"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ServiceMobileIha" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51515/ServiceMobileIha.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ServiceMobileIha"
contract="ServiceReference1.ServiceMobileIha" name="BasicHttpBinding_ServiceMobileIha" />
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
答案 0 :(得分:1)
取代:
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
与
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647" />
</system.web>
允许整体httpRuntime - &gt; maxRequestLenght增加;)
周末有个好人
答案 1 :(得分:0)
这可能是客户端的问题。您是否在客户端更改了maxReceivedMessageSize
,maxBufferPoolSize
和maxBufferSize
?
答案 2 :(得分:0)
这确实会影响maxReceivedMessageSize配置,但它可能是客户端或服务器。因为客户端正在接收回复,但服务器正在接收请求。所以这取决于哪一个太大了。例如,如果客户端正在发送大的有效负载,但是服务器发送回void或bool或小的东西,那么服务器的配置必须改变,反之亦然。