我有一个网站和wcf服务,数据库是mongodb。
我在尝试上传类时遇到错误有filestream属性(大于4mb)。 当我尝试上传较小的尺寸时,一切都很好。
如何增加上传限制?
远程服务器返回了意外响应:(413)Request Entity Too Large。
客户端配置:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime requestValidationMode="2.0" executionTimeout="360" maxRequestLength="100000" enableVersionHeader="false" />
<authentication mode="Forms" >
<forms loginUrl="~/Login.aspx" timeout="2880" protection="All" path="/" />
</authentication>
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
</handlers>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:52237/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="MyService.IMyService" name="BasicHttpBinding_IMyService" />
</client>
</system.serviceModel>
</configuration>
Wcf服务配置:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<globalization culture="tr-TR" uiCulture="tr-TR"/>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="false"/>
</system.webServer>
</configuration>
答案 0 :(得分:0)
只需将客户端配置中的maxReceivedMessageSize="10485760"
更改为maxBufferPoolSize="2147483647"
。
答案 1 :(得分:0)
试试这个:
<bindings>
<wsHttpBinding>
<!--allow big messages: 10mb = 10 * 1048576 = 10485760-->
<binding name="binding_name" maxReceivedMessageSize="10485760" messageEncoding="Mtom" sendTimeout="00:02:00">
<readerQuotas maxArrayLength="10485760"/>
</binding>
</wsHttpBinding>
</bindings>
这是我在服务器端的配置的一部分:)我有完全相同的问题,这个修改解决了它。
答案 2 :(得分:-1)
在&lt;&lt; system.serviceModel&gt;
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
答案 3 :(得分:-1)
我找到了解决方案。 wcf service config:
<configuration>
<appSettings>
<add key="ConnectionString" value="mongodb://login.f8.com.tr:19191"/>
<add key="DatabaseName" value="F8Mutabakat"/>
</appSettings>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5" />
</system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<globalization culture="tr-TR" uiCulture="tr-TR"/>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<!--<behavior name="F8ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="F8Mutabakat" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="F8LocalService.UserNamePassValidator, F8LocalService" />
</serviceCredentials>
</behavior>-->
<behavior>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<!-- The name of the service -->
<service name="F8LocalService.F8mBelgeService">
<!--you can leave the address blank or specify your end point URI-->
<endpoint binding="basicHttpBinding" bindingConfiguration="F8ServiceMaxTransfer" contract="F8LocalService.IF8mBelgeService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="F8ServiceMaxTransfer" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
transferMode="Streamed"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
<!--<binding name="F8ServiceBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
-->
<!--<security mode="Message">
<message clientCredentialType="UserName"/>
</security>-->
<!--
</binding>-->
</basicHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>