I have a ASP.NET MVC 4 application with Web API. It's working great. But one problem is that IE can't download a file from a web api while chrome and firefox can. The browser says
"Unable to open this internet site. The requested site is either unavailable or cannot be found."
According to IE 8 and client-side caching, it looks like that no-cache setting causes the problem. So I want to set private cache in that download. But in MVC 4, I found there is no property "Cache" in HttpResponseMessage nor any way to set private cache. Could anybody show how to do this?
Update 1: According to my debugging, it was not cache, but `ContentDisposition' in following code.
HttpResponseMessage response = new HttpResponseMessage();
response.StatusCode = HttpStatusCode.OK;
response.Content = new StreamContent(result);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-excel");
// response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
// {
// FileName = "PY75.xls"
// };
return response;
If I commented like above, IE can download the file with id as its default file name but it cannot like what described above when uncommenting above. Any idea how to fix this problem? Why IE can't recognize content-disposition header?
Update 2: After upgrading IE 9, content-disposition is finally working and can download from web api.