troubleshooting Question

Return StreamContent with ajax call

Avatar of Moti Mashiah
Moti MashiahFlag for Canada asked on
16 Comments2 Solutions200 ViewsLast Modified:
Hi Guys,
I am using MVC project.
I have an AJAX call from the UI side that goes to the server and return Picture as "StreamContent" (that is a type of .net class return).

Here is the way I call this method that returns StreamContent:

 function ClickTest() {
             var url = ""
             var ajaxOptions = {};
             ajaxOptions.cache = false;
             ajaxOptions.url = "http://localhost:20050/api/Raster/Load";
             ajaxOptions.type = "GET";
             ajaxOptions.headers = {};
             ajaxOptions.headers.Accept = "application/octet-stream";
    = { uri: url, pageNumber: 1, resolution: 0, mimeType: "", bitsPerPixel: 0, qualityFactor: 0, imageWidth: 0, imageHeight: 0 };
             ajaxOptions.success = function (result) {
                 $("#imgid").html("<img src=" + result + ">");

It seems that I get some binary result but when I place it in the dom I don't get the picture.

There is any way to convert this result and put it like a picture.

Example of the result I am getting.

Join our community to see this answer!
Unlock 2 Answers and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros