简体   繁体   中英

How to allow anonymous user to browse the Style folder

In my web application I want the anonymous user to browse only the login page, and It's OK now but it appears without style!

<authorization>
    <deny users="?"/>
    <allow users="*"/>
</authorization>

</system.web>

<location path="Style">
  <system.web>
    <authorization>
      <allow users="?" />
    </authorization>
  </system.web>
</location>

Any help!

From this article :

Images and CSS files

Say you have all your images and CSS in a seperate folder called images and you are denying anonymous access to your website. In that case you might see that on your login page you cannot see images(if any) and css(if any) applied to your login page controls.

In that case you can add a web.config to the images and css folder and allow access to everyone to that folder. So your web.config in images folder should look as below:

<configuration>
   <system.web>
      <authorization>
        <allow users="*"/> //Allow everyone
      </authorization>
   </system.web>
</configuration>

The most popular answer of:

<configuration>
   <system.web>
      <authorization>
        <allow users="*"/> //Allow everyone
      </authorization>
   </system.web>
</configuration>

..is correct.. but if this fails to work then you need to verify that the Authentication is setup as you expect and that the user under which Anonymous is configured to run has read access to all of the folders you need.

NOTE: If you have multiple web.configs you may need to check each folder with its own web.config.

Check the Web Application

Open the "IIS/Authentication" for your web application and click "edit" on the entry marked "Anonymous Authentication".

  • If a specific user is specified then ensure that the specified user has access to your folders.
  • If "Application pool identity" is set then you will need to check the application pool configuration.

Check the Application Pool

Find the Application Pool for your app and click on "Advanced Settings" and search for the item named "Identity".

If the identity is "ApplicationPoolIdentity" then the group you will need to give access to your files to "IIS_IUSRS".

For more information on "IIS_IUSRS" please see: http://learn.iis.net/page.aspx/140/understanding-built-in-user-and-group-accounts-in-iis/

use

        <allow users="*" />

for styles folder, so every user can use the style.

  1. using

     <location path="admin"> <system.web> <authorization> <deny users="*" /> <allow users="?" /> </authorization> </system.web> </location> 

you can allow access to Admin folder for only authenticated users.

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