在IIS 7.5執行某個ASP.NET程式時發生以下錯誤:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:
Module: IpRestrictionModule
Notification: BeginRequest
Handler: PageHandlerFactory-Integrated
Error Code: 0x800700b7
Config Error: Cannot add duplicate collection entry of type 'add' with combined key attributes 'ipAddress, subnetMask, domainName' respectively set to '192.168.1.73, 255.255.255.255, '
Config File: Unavailable (Config Isolation)

Config Source:
<ipSecurity> <add ipAddress="192.168.1.73" allowed="true" /> </ipSecurity>

看起來好像是我設的IP存取限制發生衝突,不過我一直都是用IIS Manager設定的,不知為何會冒出這種錯誤。於是我開啟IIS管理員要檢視有問題Web Application的"IP Address and Domain Restrictions"設定時,冒出以下錯誤:

---------------------------
IP Address and Domain Restrictions
---------------------------
There was an error while performing this operation.

Details:

Filename: \\?\C:\Windows\system32\inetsrv\config\applicationHost.config

Line number: 1719

Error: Cannot add duplicate collection entry of type 'add' with combined key attributes 'ipAddress, subnetMask, domainName' respectively set to '192.168.1.73, 255.255.255.255, '

這裡的訊息明確很多,直指問題出在applicationHost.config。找到該檔案,果然查到所謂"重覆"是什麼:

預設網站有此192.168.1.73的設定:

<location path="Default Web Site">
    <system.webServer>
        <security>
            <ipSecurity allowUnlisted="false">
                <add ipAddress="127.0.0.1" allowed="true" />
                <add ipAddress="192.168.1.73" allowed="true" />
            </ipSecurity>
        </security>
    </system.webServer>
</location>

該Web Application裡也有相關設定:

<location path="Default Web Site/PlayGround">
    <system.webServer>
        <security>
            <ipSecurity>
                <add ipAddress="192.168.1.73" allowed="true" />
            </ipSecurity>
        </security>
    </system.webServer>
</location>

將Default Web Site/PlayGround的<add ipAddress="192.168.1.73" allowed="true" />設定刪除,問題就解決了。但從未手動修改此檔,一向都只用IIS管理員設定,為何會搞出這種矛盾錯誤,原因成謎...


Comments

Be the first to post a comment

Post a comment