protecting files with asp.net (mvc) -


i want protect files in specific directory people cannot link them - still need program capable of rendering them, password protecting actual folder won't work. there way facilitate in asp.net mvc? it's more asp.net, not mvc - can't make use of things session state , postback , such...

you put directory outside of web app's root directory (so can't accessed using copied url) or directory deny read access using web.config file.

then access files through action requires current user authorized, e.g:

public class filecontroller : controller {   [authorize]   public actionresult get(string file)   {     return new file(path.combine(_rootpath, file);   } } 

then can access files through action url, e.g. http://server/app/file/get/test.txt.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -