3 windows iis-7 asp.net windows-authentication
是否可以使用 Windows 身份验证对 ASP.net 应用程序的一个或多个子文件夹禁用 Windows 身份验证?
例如:
一个网站包含几个其他文件夹,其中包含整个应用程序的部分:/frontend、/backend、/login
bin 文件夹与这些子文件夹位于同一级别,即网站的根目录。
所有这些子文件夹都包含使用位于网站根目录的 bin 文件夹中的二进制文件的页面。
用户在访问后端文件夹中的页面时必须输入 Windows 凭据,但在访问登录或前端文件夹中的页面时则不必输入 Windows 凭据。
我正在使用 IIS7
有任何想法吗?
小智 8
找到了解决办法:
调整了 applicationHost.config 文件,并将 anonymousAuthentication en windowsAuthentication 部分条目的“overrideModeDefault”更改为“Allow”
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<section name="windowsAuthentication" overrideModeDefault="Allow" />
Run Code Online (Sandbox Code Playgroud)在 web.config 中为需要从 Windows 身份验证中排除的每个文件夹/文件添加了位置标记
<location path="pathToDirOrFile">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)确保这些文件夹中的每一个都包含一个单独的 web.config 文件,以禁用身份模拟
<configuration>
<system.web>
<identity impersonate="false" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)