为匿名用户IIS 7.5授权一个目录?

时间:2011-02-04 18:29:40

标签: asp.net iis-7

我正在尝试在IIS 7.5中为匿名访问添加目录。它适用于Web Dev,但不适用于IIS 7.5

我目前正在目录中使用此web.config。这是一个带样式表的目录:

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->

    <configuration>
        <appSettings/>
        <connectionStrings/>
        <system.web>
            <authorization>

                <allow users="*" />

            </authorization>

        </system.web>
    </configuration>

更新

我已经转到该文件夹​​并在身份验证下,我已将IIS_USR中的匿名身份验证更改为池。这似乎是正确的。

我将奖励任何为理解此设置提供非常好的解释和资源的人。此外,如何全局应用它将很有用 - 对于所有文件夹。

2 个答案:

答案 0 :(得分:7)

既然你回答了自己的问题,这里的解释可能会有所帮助

授权处理IIS将向谁提供资源。但是,这些资源有自己的安全性,因为它们只是文件系统上的文件。

配置中的Authentication元素有助于确定IIS在接受用户请求后如何识别用户的请求,以及访问IIS之外/之外的资源。

这是在站点级别设置的,通常位于服务器的applicationHost.config文件中。如果设置正确,可以在站点级别覆盖它。

IIS.net网页关于此:

http://www.iis.net/ConfigReference/system.webServer/security/authorization/add

http://www.iis.net/ConfigReference/system.webServer/security/authentication/anonymousAuthentication

您在UI中执行的.config版本是:

<location path="/yourSite">
   <system.webServer>
      <security>
         <authentication>
            <anonymousAuthentication enabled="true" username="" />
          </authentication>
      </security>
   </system.webServer>
</location>

在anon上。 auth方法,用户名字段是IIS在访问资源时将模拟的对象。如果未指定,则默认使用apppool的标识。

现在,至于为什么这很重要...检查磁盘上的实际文件(.css)。如果这解决了问题意味着IUSR无权读取该文件。

答案 1 :(得分:0)

您没有为您的授权定义位置。您也没有在web.config(如果有)中指定您正在使用的身份验证类型。

<location path="/">
    <system.web>
    <authorization>
        <allow users="*"/>
        </authorization>
    </system.web>
</location>
相关问题