Returning binary file from controller in ASP.NET Web API

后端 未结 8 781
离开以前
离开以前 2020-11-22 02:55

I\'m working on a web service using ASP.NET MVC\'s new WebAPI that will serve up binary files, mostly .cab and .exe files.

The following co

8条回答
  •  一向
    一向 (楼主)
    2020-11-22 03:34

    You can try the following code snippet

    httpResponseMessage.Content.Headers.Add("Content-Type", "application/octet-stream");
    

    Hope it will work for you.

提交回复
热议问题