NullReferenceException when returning a BLOB stream in MVC after upgrading to Storage 2.1.0.3

I have several Actions in my MVC controllers that return BLOB azure by passing a blob stream to FileResult. Like this:

    public FileResult DownloadReport(string Id)
    {
        // Look up model
        string fileName = messenger.ReportTitle(Id);

        // Get a reference to the blob
        CloudBlockBlob mainReportBlob = cloudBlobContainer.GetBlockBlobReference(Id);

        // Return as a FileResult
        using (var reportReader = mainReportBlob.OpenRead())
        {
            return File(reportReader , "application/pdf", fileName );
        }
    }

I recently updated my Azure Storage library recently and started getting the following exceptions:

System.NullReferenceException
 HResult = -2147467261
 Message = ​​ .
  = Microsoft.WindowsAzure.Storage
 StackTrace:
       Microsoft.WindowsAzure.Storage.Blob.BlobReadStreamBase.ConsumeBuffer( Byte [], Int32, Int32) e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\Common\Blob\BlobReadStreamBase.cs: 222
       Microsoft.WindowsAzure.Storage.Blob.BlobReadStream.Read( Byte [], Int32, Int32) e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Blob\BlobReadStream.cs: 72
       System.Web.Mvc.FileStreamResult.WriteFile( HttpResponseBase)
       System.Web.Mvc.FileResult.ExecuteResult( ControllerContext)
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 , Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)

, , Azure. ?

+4
1

, , , BlobReadStreamBase.Dispose() , . , , File() , MVC, .

, using() Blob , MVC . :

    public FileResult DownloadReport(string Id)
    {
        // Look up model
        string fileName = messenger.ReportTitle(Id);

        // Get a reference to the blob
        CloudBlockBlob mainReportBlob = cloudBlobContainer.GetBlockBlobReference(Id);

        // Return as a FileResult, DON'T place in a using() block or it will be closed early
        var reportReader = mainReportBlob.OpenRead();
        return File(reportReader , "application/pdf", fileName );
    }

. , , BlobReadStreamBase.Dispose() , MVC .

, , . , , Azure?

+6

All Articles