简体   繁体   中英

access to static files on IIS

how to restrict access to files such as gif, jpeg, .js and css files to unauthorized users in an ASP.NET web application? The site is configured with Anonymous access on IIS 8. The content should be hidden/blocked until the user logs in succesfully.

You can use forms authentication for that.Copy all your static files in folder Where you can protect your folder and allow only for authenticated users just like below.

<location path="Relative path for folder">
  <system.web>
     <authorization>
       <deny users="?"/>
     </authorization>
   </system.web>
 </location>

Here CSS is path of folder Here is a complete example.

http://www.codefixer.com/asp-net/tutorials/protecting-folders-with-forms-authentication.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM