I'm following the Official Azure Blob Upload Documentation and I successfully implemented a blob uploading functionality. However the page refreshes after uploading and I need to make it in such as a way that the image is uploaded without the page having to refresh. Basically no postback.

Here's what I have so far:

       if (profile_pic_input.HasFile)
                var image = Request.Files["profile_pic_input"];

                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
                CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer container = blobStorage.GetContainerReference("photos");
                if (container.CreateIfNotExists())
                    // configure container for public access
                    var permissions = container.GetPermissions();
                    permissions.PublicAccess = BlobContainerPublicAccessType.Container;

                String tempName = GeneratePictureName();
                string uniqueBlobName = string.Format("photos/image_{0}{1}", tempName, Path.GetExtension(image.FileName));
                CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);

                blob.Properties.ContentType = image.ContentType;

Related posts

Recent Viewed