I have a folder in my website which contains another folder which contains many folders which all contain various documents: pdfs, word documents, txt files, excel documents, images etc. I want to prevent users from navigating to any of these documents via the browser. How can I do this? I am using MVC3.
Share
You could move your directory structure inside the
App_Dataspecial folder. This folder is not directly accessible. Then simply write a controller action which given an id will stream the file to the client. Then decorate the controller action with the Authorize attribute to ensure that only authenticated users can access them.