简体   繁体   中英

Getting “The image cannot be decoded. The image header might be corrupted” error while reading list of images from WCF service

I'm saving my images in the form of bytes in the database.When I try to fetch the images from database using WCF , it gives me the error "The image cannot be decoded. The image header might be corrupted." .For this , I have increased the size in web config. Below is the code I'm using but I'm getting the same problem.Please Let me know where I'm wrong.

<bindings>
      <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000"
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32"
               maxArrayLength="200000000"
               maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>

In wcf need to add below code in order to get rid off this error

<bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="10485760">
          <readerQuotas maxDepth="2147483647"
                         maxStringContentLength="2147483647"
                         maxArrayLength="2147483647"
                         maxBytesPerRead="2147483647"
                         maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

Also needs to add the same in app.config on client machine

<bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="10485760">
          <readerQuotas maxDepth="2147483647"
                         maxStringContentLength="2147483647"
                         maxArrayLength="2147483647"
                         maxBytesPerRead="2147483647"
                         maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM