J
J
jammywork12015-01-11 04:42:11
MIME types
jammywork1, 2015-01-11 04:42:11

How to configure iis, staticContent, mimeMap for different content paths?

Hello. I am developing a small web project, in some way file hosting. Upon request through a web form, the user receives a link to the file and downloads it. Files of various types, and I would like such types as jpg , pdf and so on. were not opened in the user's tab for viewing, but it was suggested to save / open them. For this, a solution was found: in the applicationhost.config section, put any file and the browser perceived it as an unfamiliar type.
But in this case there is a problem with static content, pictures, css , javascript .
Question : is it possible to specify mimeMap in the configfor a specific path, for example for static content the actual mimeType , and for files to be served to the user mimeType="application/xz"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2015-01-11
@jammywork1

First: It is
better to initially build the project structure so that the file storage is independent and does not bring down the main site at high loads, and so that in the future it will be easier to scale the project.
Simply put, at a minimum, you should use different domains/sites for file repositories.
For example, the main site:
And the file storage:
Even hosting the main site and storage(s) on the same server, it will be possible to distribute the load between projects.
Then the problem with mime will disappear by itself.
Second: If the files are served by the server code, then it is enough to add the Content-Disposition header so that the browser prompts the user to download the file:

Response.AddHeader("Content-Disposition", "attachment; filename=123.gif");

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question