Friday, 15 May 2015

asp.net mvc - Returning FileResult does not pick up MIME type in IE9 -



asp.net mvc - Returning FileResult does not pick up MIME type in IE9 -

i have method on controller returns files

public fileresult downloadfile(int id) { var file = _repository.getinidividualfile(id); homecoming file(file.filebinary, file.contenttype, file.filename); }

the file object returning values correctly ie9 isn't picking content type. current list of file types have are:

'application/pdf'

'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'

'application/vnd.ms-excel'

all other browsers seem working fine ie seems ignore extension. problem have because file has been downloaded without extension, user prompted select application open file have no idea.

i have tried in firefox, chrome, safari , opera , fine

here's view of debugger showing values beingness returned

here's output fiddler showing content type:

http/1.1 200 ok

server: asp.net development server/10.0.0.0

date: tue, 19 feb 2013 10:16:41 gmt

x-aspnet-version: 4.0.30319

x-aspnetmvc-version: 3.0

content-disposition: attachment; filename="provisioning tool"

cache-control: private

content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

content-length: 491470

connection: close

after messing around have found is. ie expects extension on file name despite having content type. so,

return file(file.filebinary, "application/pdf", "test");

won't work,

return file(file.filebinary, "application/pdf", "test.pdf");

does.

asp.net-mvc internet-explorer-9

No comments:

Post a Comment