Reputation: 20658
I am developing a CDN server that is a normal MVC project. However, in the project folder, suppose I have CDN
folder, and I want everyone are allowed to access any files in there, with any file extension, and for CDN
folder only. That is, I don't want my web.config
file or Views
folder for example to be exposed.
Is there any way to do this without using a custom Controller
or RouteHandler
?
EDIT: As specified I am looking for a way in IIS or Web.config or somewhere else of writing code in Controller or RouteHandler, so it is not a duplicate.
Following David Gunderson answer, here is my web.config that allow CDN folder:
<location path="CDN">
<system.webServer>
<staticContent>
<mimeMap fileExtension="*" mimeType="application/octet-stream"/>
</staticContent>
</system.webServer>
</location>
Upvotes: 4
Views: 4384
Reputation: 721
You can configure location settings for specific sub directories of your site in your web config:
https://msdn.microsoft.com/en-us/library/ms178692%28v=vs.140%29.aspx
The following would grant all users access to the contents of the CDN folder if placed in your root web.config. It will grant access to anonymous users even if you have forms authentication turned on for the rest of your site:
<location path="CDN">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
Upvotes: 5