1

I have implemented a fileupload in my ASP.NET 4.0 WebSite which runs in Azure. The AJAX Call to the WCF-Service works fine locally, but when i deploy it to Azure it fails with the following Exception:

System.Web.HttpException Request.BufferlessInputStream can not be used because the Request's contents have already been read.

at the following line:

HttpContext.Current.Request.GetBufferlessInputStream().Read(COMPLETEBufferedFileContent, 0, fileContentLength);

My WebService-Method is declared like:

public Stream UploadProfileImage()

And a part of my configuration for the service looks like:

<bindings>
  <customBinding>
    <binding name="NiPDefaultCustomBinding" 
             openTimeout="00:01:00" 
             closeTimeout="00:01:00" 
             sendTimeout="00:01:00" 
             receiveTimeout="00:01:00" >   
      <sslStreamSecurity/>    
      <webMessageEncoding webContentTypeMapperType="XXXMapperForStreamInParamAndJSON, AssemblyX">
        <readerQuotas maxArrayLength="16384"
                      maxBytesPerRead="4096"
                      maxDepth="32"
                      maxNameTableCharCount="16384"
                      maxStringContentLength="8192" />
      </webMessageEncoding>    
      <httpsTransport maxBufferPoolSize="524288"
                      maxBufferSize="65536" 
                      maxReceivedMessageSize="6291456" 
                      transferMode="Streamed" 
                      manualAddressing="true">       
      </httpsTransport>
    </binding>
  </customBinding>

My XXXMapperForStreamInParamAndJSON overrides GetMessageFormatForContentType() and returns WebContentFormat.Raw in this scenario.

I know that i am using streaming, but buffering the complete content which doesn't make sense for streaming, but in this case it doesn't make a problem, because i upload images with this method and i need to create a thumbnail, so i need the bitmap anyway complete in buffer / memory.

I do not access .Form, .Files or .InputStream or any other relevant from the Request-Object, so i don't understand why the call fails in azure, but works locally. Everything is 100% the same.

Can anybody help me, please?

Please, has anybody a tip for me? This problem is very hard and it is very important that i fix this, because otherwise i have no chance to get online on azure some day.

4

0 回答 0