Reputation: 2825
Click to download Excel File
I am using the above hyper link in my application to allow the users to download an Excel file.When I click on the hyperlink button it is displaying a file download dialogue box, but when I do the same thing in the server it is opening the Excel file as a web page.
What would be the reason for this issue?
Please help.
Upvotes: 0
Views: 457
Reputation: 54854
This happens because your browser in one of the boxes knows how to handle an Excel spreadsheet, probably because you installed Excel and the other box doesn't know how to handle Excel. This is all controlled by the Content
headers. Right now you are sending only the MIME type in the Content-Type
header. What you need to do is also send the Content-Disposition
.
You need to set the Content-Disposition on the header.
Content-Disposition = attachment; filename=filename.xls
Or, if you cannot modify the application, which it doesn't sound like is the case, you can modify the MIME type to
Content-Type = application/download
You can find an example of this in this KB article.
Upvotes: 1