How do I protect static files with ASP.NET form authentication on IIS 7.5? -
I have running on a shared host on ASP.NET 4.0 on IIS 7.5 server, but in full confidence.
The site is an original "file browser" that allows visitors to login and display a list of available files for them, and of course, download files static files (mostly PDF files) Are located in a sub folder on a site called, e.g. ...
The site uses ASP.NET form authentication.
My question is: How do I obtain the ASP.NET engine to handle requests for static files in the data folder, so that requests for files can be authenticated by ASP.NET, and users Not able to have a file and grab links to grab files from them?
Regards, Egil.
Text after "div class =" itemprop = "text">
If you are running the application pool in integrated mode, you can do the following.
Add the following to your top-level web.config.
& lt; System.webServer & gt; & Lt; Module & gt; & Lt; Add name = "FormsAuthenticationModule" type = "System.Web.Security.FormsAuthenticationModule" /> & Lt; Remove name = "URL Authorization" /> & Lt; Add name = "url authorization" type = "System.Web.Security.Url authorization module" /> & Lt; Remove name = "DefaultAuthentication" /> & Lt; Add name = "DefaultAuthentication" type = "System.Web.Security.DefaultAuthenticationModule" /> & Lt; / Module & gt; & Lt; /system.webServer>
Now you can use standard ASP.NET in your web.config to force forms for all files in the directory
. & Lt; System .web & gt; & Lt; Authority & gt; & Lt; Deny users = "?" / & Gt; & Lt; / Authorization & gt; & Lt; Authentication mode = "form" / & gt; & Lt; /system.web>
Comments
Post a Comment