I'm having an Image in the form of Byte Array, from that I'm converting Byte Array from the following C# method
public HttpResponseMessage ReturnBytes(byte[] bytes)
{
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(bytes);
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
return result;
}
My HTML Source Code:
<div ng-app="myApp" ng-controller="myCtrl">
<div id="div_image"></div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("someurl")
.then(function(response) {
$scope.imageSrc = response.data;
$('.div_image').html('<img src="data:image/png;base64,' + $scope.imageSrc + '" />');
});
});
</script>
Reference Links I have followed :
- How to Get byte array properly from an Web Api Method in C#?
- Display png image as response to jQuery ajax request
I Can't able to load the image in the HTML View. Kindly assist me...