2

Masters,

I have a scenario where i have a list of Items and on clicking single item it gets details along with image src url using ajax call.

I want to display(render) image right on page.

Now Image source URL is a FileActionResult returning Base64 string.

The problem is the page does not render image although it is having correct Src URL. And I don't want any additional Ajax call.

Please Help. Thanks in advance.

2
  • Why a base64 string when you can directly send an image stream as file result? any specific reason. While a base64 works on <img src="data:image/png;base64,..."/> kind of funda. Commented Jan 2, 2014 at 17:41
  • Ref 1 Ref 2 go through these two references.Might help you out. Good Luck! Commented Jan 2, 2014 at 17:51

1 Answer 1

1

How are you forcing the image to be updated?

The DOM is going to keep the image the same until you tell it to refresh the image -- I would suggest using something like

document.getElementById('theImg').src="/newImg.gif?unique=someuniquestring"; 

where someuniquestring is a new random datetime or something (to make sure browsers like IE don't cache the GET request).

Sign up to request clarification or add additional context in comments.

3 Comments

But I am assigning it a URL that will definitely give you image. Something like <img src="/File/DownloadFile/1" />. If you punch same in another tab then it shows image. The only constraint is, the response is base64 string
Ah, so it's not exactly a File getting returned from your FileActionResult, is it?
File is returned as wanted if i open it in another tab but not rendering in Image box

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.