How to Deny Access to specific folder in ASP.Net MVC 5

Viewed 3196

I have one "Upload" folder in my project directory where I upload files & images. To get access to these files only by authorized access, I created a authorize Downloads Controller & provides files by that way. But if someone tried http://domain_name/Upload/filename.ext then that file accessible in browser. I want to restrict this Upload folder access to anonymous users. For this I tried: http://prideparrot.com/blog/archive/2012/6/authorizing_folders_using_routeexistingfiles https://stackoverflow.com/a/18218084/5756211 But nothing works for me. Thanks for the help in Advance.

2 Answers

Use below code if someone could not able to find a solution for this issue.

<?xml version="1.0" encoding="UTF-8"?> 
<configuration>
    <system.webServer>
         <security>
             <authorization><add accessType="Deny" users="?"/></authorization>
         </security>
    </system.webServer>
</configuration>'
Related