0

IIS 7.5 でホストされている ASP.net アプリケーションがあり、このアプリケーションで匿名アクセスが有効になっているかどうかをアプリケーション内で確認したいと考えています。

私はこれが提供すると思った:

AnonymousAuthenticationSection section = WebConfigurationManager.OpenSection("system.webServer/security/authentication/anonymousAuthentication") as AnonymousAuthenticationSection;
return section.Enabled;

ただし、 applicationHost.config の関連部分が適切に見える場合でも、 section は常に null です。

<location path="Default Web Site/TestApp">
    <system.webServer>
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" userName="" />
                <windowsAuthentication enabled="true">
                    <providers>
                        <clear />
                        <add value="NTLM" />
                        <add value="Negotiate" />
                    </providers>
                </windowsAuthentication>
            </authentication>
        </security>
    </system.webServer>
</location>

なぜこれがnullなのか誰か教えてもらえますか? ありがとう。

4

0 に答える 0