c# - Block direct access to a file over but allow via http using asp.net -


I am using the code to download the file in my intranet asp.net web application. But a user hacked and found the shared folder path of the file. How to prevent it?

  System Web. HTPRS Response = System Web. Hpptx Running response; Response.ClearContent (); Response.Clear (); reaction. Content type = "text / plain"; reaction. Add Header ("content-dispute", "attachment; file name =" + filename + ";"); Response.TransmitFile (Server.MapPath ("FileDownload.pdf")); Response.Flush (); Response.End (); Using the Directory Browsing Option (IIS 7) you can disable it in IIS:  

Enter image details here

Or you can do it yourself Change your own and add the following options:

  & lt; Configuration & gt; & Lt; System.webServer & gt; & Lt; DirectoryBrowse enabled = "false" /> & Lt; /system.webServer> & Lt; / Configuration & gt;  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -