Returning binary file from controller in ASP.NET Web API

后端 未结 8 786
离开以前
离开以前 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:48

    The overload that you're using sets the enumeration of serialization formatters. You need to specify the content type explicitly like:

    httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
    

提交回复
热议问题