Click here to Skip to main content
15,936,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I set "cloud web site", "SQL DB", "BLOB"... onto azure.
Here is the thing I want to do:
Get image from BLOB(azure) through ashx file and show out the image in web page (element:image).

It can't find any photo and show error:
Error code>>>
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

ashx code>>>
CloudStorageAccount storage = CloudStorageAccount.Parse(string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageName, storageKey));
CloudBlobClient cloudBlobClient = storage.CreateCloudBlobClient();

CloudBlobContainer container = cloudBlobClient.GetContainerReference("memid" + MemID);
container.CreateIfNotExist();

CloudBlob obj = container.GetBlobReference(PhotoHash);
BlobStream blobstream = obj.OpenRead();
Image img = null;
img = Image.FromStream(blobstream, true);

context.Response.ContentType = "image/jpeg";
var byteArray = obj.DownloadByteArray();
context.Response.OutputStream.Write(byteArray, 0, byteArray.Length);

aspx code>>>
var PldImg = $('<img></img>')
.attr('src', 'LoadFriendsPhoto/LoadPhotoFromBlob.ashx?MemID=' + MemID + '&PathNameData=' + friInfo[i - 1].PhotoHash);

p.s PhotoHash is the BLOB file name, example: 004dae3947219415f5899b2d6bbe9637
How can I fix this?
Thanks.
Posted

1 solution

I've fixed this. Just use 'url' can solve it.
Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900