在下面的代码中,我想使用wcf显示img。其中我只能显示20kb大小的图像而大于20kb的大图像没有显示任何一个帮助我解决这个问题。
<input type="hidden" id="imgname" runat="server" />
<input type="hidden" id="imgid" runat="server" />
[WebMethod]
public static string buttonclickImage(string DocumentName,string Documentid)
{
string strClientName = ConfigurationManager.AppSettings["ClientName"].ToString();
string Docurl = strClientName + "\\Documents\\" +Documentid+"_"+ DocumentName;
FileServiceClient fileTranz = new FileServiceClient();
FileDto file = fileTranz.GetDocumentImage(Docurl);
var fileData = Convert.ToBase64String(file.Content);
return fileData;
}
JS:
function UpdateImage() {
var Code = document.getElementById('<%= imgname.ClientID %>').value;
var DOCID = document.getElementById('<%= imgid.ClientID %>').value;
PageMethods.buttonclickImage(Code,DOCID, onSucess, onError);
function onSucess(result) {
//alert("Success");
document.getElementById('<%=docimg.ClientID%>').src = 'data:image/gif;base64, ' + result;
}
function onError(result) {
// alert(result);
// alert('Something wrong.');
}
}
Webconfig
<binding name="BasicHttpBinding_IFileService" 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="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
答案 0 :(得分:0)
前一天我也面临同样的问题。 这是由于WCF服务调用中的参数长度而发生的。 修改您的web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding>
<readerQuotas
maxDepth="64"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
...
</system.serviceModel>