使用Silverlight和WCF上传文件 [英] File Upload using Silverlight and WCF
问题描述
我正在尝试使用Silverlight和WCF读取文件(文件流)。我在WCF配置中使用了basicHttpBinding并创建了一个数据契约来捕获文件内容为byte [](字节数组)。
I am trying to read the file (file stream) using Silverlight and WCF. I have used basicHttpBinding in WCF configuration and created a data contract to capture the file contents as byte[] (byte array).
当我尝试发送文件内容(字节数组)时从Silverlight到WCF代理,我收到CommunicationException错误。
when I am trying to send the file content (byte array) from Silverlight to WCF proxy, I am getting CommunicationException error.
事实上,我按照以下博客中提到的相同步骤进行操作 - http://www.dotnetspark.com/kb/1510 -file-upload-from-silverlight-using-wcf-server.aspx
Infact, I follow the same steps as mentioned in the following blog - http://www.dotnetspark.com/kb/1510-file-upload-from-silverlight-using-wcf-server.aspx
任何帮助都将不胜感激。
Any help would be appreciated.
谢谢和问候,
Vishal Mantri
Vishal Mantri
推荐答案
多少bytes是文件?您可能有引用问题。
How many bytes is the file? You probably have a quote problem.
您的服务器上的web.config文件应该定义您的配额,否则配额非常小:
Your web.config file at the server should have your quotas defined, otherwise the quota is very small:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="1048576" maxBufferSize="1048576" maxBufferPoolSize="1048576">
<readerQuotas maxBytesPerRead="32768" maxStringContentLength="1048576" />
这篇关于使用Silverlight和WCF上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!