title: Windows Azure : Storage Client Exception Unhandled
body: <p>I am writing a code for upload large files into the blobs using blocks... When I tested it, it gave me an StorageClientException</p>
  
  <p>It stated: One of the request inputs is out of range.</p>
  
  <p>I got this <strong>exception</strong> in this line of the code:</p>
  
  <pre><code>blob.PutBlock(block, ms, null);
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>protected void ButUploadBlocks_click(object sender, EventArgs e)
          {
  
              // store upladed file as a blob storage
              if (uplFileUpload.HasFile)
              {
                  name = uplFileUpload.FileName;
                  byte[] byteArray = uplFileUpload.FileBytes;
                  Int64 contentLength = byteArray.Length;
                  int numBytesPerBlock = 250 *1024; // 250KB per block
                  int blocksCount = (int)Math.Ceiling((double)contentLength / numBytesPerBlock);  // number of blocks 
                  MemoryStream ms ;
                  List&lt;string&gt;BlockIds = new List&lt;string&gt;();
                  string block;
                  int offset = 0;
  
                  // get refernce to the cloud blob container
                  CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("documents");
  
                  // set the name for the uploading files
                  string UploadDocName = name;
  
                  // get the blob reference and set the metadata properties
                  CloudBlockBlob blob = blobContainer.GetBlockBlobReference(UploadDocName);
                  blob.Properties.ContentType = uplFileUpload.PostedFile.ContentType;
  
                  for (int i = 0; i &lt; blocksCount; i++, offset = offset + numBytesPerBlock)
                  {
                      block = Convert.ToBase64String(BitConverter.GetBytes(i));
                      ms = new MemoryStream();
                      ms.Write(byteArray, offset, numBytesPerBlock);
  
                      blob.PutBlock(block, ms, null);
                      BlockIds.Add(block);
                  }
  
                  blob.PutBlockList(BlockIds);
  
                  blob.Metadata["FILETYPE"] = "text";
              }
          }
  </code></pre>
  
  <p>Can anyone tell me how to solve it...</p>