简体   繁体   English

访问IIS上的静态文件

[英]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? 如何在ASP.NET Web应用程序中将未经授权的用户限制访问gif,jpeg,.js和css文件等文件? The site is configured with Anonymous access on IIS 8. The content should be hidden/blocked until the user logs in succesfully. 该站点在IIS 8上配置了匿名访问。应隐藏/阻止内容,直到用户成功登录为止。

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. 这里CSS是文件夹的路径这是一个完整的示例。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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