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
Post a Comment