I have some files in my Content folder that I don’t want a user to be able to download without being authorised. How do I prevent a user from just getting to the file by typing …Content/{filename} into the address bar?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are a couple of possibilities. The first one consists into using the
<location>tag in your web.config:Another possibility is to put those files inside a folder where noone can access (like the App_Data folder for example) and then have a controller action that will serve those files which will be decorated with the
[Authorize]attribute.