玩转CSLA.NET小技巧系列二:使用WCF无法上传附件,提示413 Entity Too Large
背景:由于系统需要展示图片,客户上传图片到本地客户端目录,然后在数据库中存储本地图片地址,和图片二进制数据
错误原因:我是使用CSLA的WCF服务,使用了数据门户,WCF协议使用的是wsHttpBinding,上传图片大小为512KB,并且已经配置了
<httpRuntime maxRequestLength="2147483647"/> <wsHttpBinding> <binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" messageEncoding="Mtom"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> </binding> </wsHttpBinding>
上传限制到2GB,但是还是没有办法上传512KB的图片
但是我切换到basicHttpBinding时,竟然可以上传
<httpRuntime maxRequestLength="2147483647"/> <basicHttpBinding> <binding name="basicHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"> <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" maxDepth="2147483647" /> </binding> </basicHttpBinding>
说实话我对WCF不是很熟悉,希望知道原因的能留个言,大家讨论下