return an image using ASP.NET Web API and display it?

后端 未结 1 1773
眼角桃花
眼角桃花 2021-01-17 05:57

web api action :

byte[] bytes = System.IO.File
                        .ReadAllBytes(
                          HttpContext.Current.Server.MapPath("~/I         


        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 06:33

    You don't need to make an AJAX call to this action. Just put an tag and point its src property to your Web API endpoint:

    
    

    or if you don't know the accountId in advance, you could construct this img tag dynamically and inject it into the DOM using javascript:

    var id = '12345';
    $('#someDivId').prepend('');
    

    and the image will be added to a container that you need to have in your DOM:

    0 讨论(0)
提交回复
热议问题