Asp.net
web.config ipSecurity 的內部伺服器錯誤
這是我的 web.config,其中有一些用於阻止 Ipaddress 的標籤
<configuration> <connectionStrings> ... </connectionStrings> <appSettings> .... </appSettings> <runtime> .... </runtime> <system.webServer> <security> <ipSecurity allowUnlisted="false"> <clear/> <add ipAddress="127.0.0.1" allowed="true"/> <add ipAddress="83.116.19.53" allowed="true"/> </ipSecurity> </security> </system.webServer> </configuration>我的意圖是阻止除上述之外的任何其他 IP。以上是我希望網站可以訪問的唯一 IP 地址。但是使用“ipSecurity”標籤,我總是收到 500 - 內部伺服器錯誤,沒有它,網站執行良好。
我已確保在伺服器上安裝了“IP 和域限制”。如果我遺漏了什麼,請告訴我。謝謝你。
對於遇到此問題的其他人。問題的原因是功能委派不允許該功能由 web.config 管理。
修理:
驗證是否為 web.config 管理啟用了該功能
在 IIS 7 中,點擊根伺服器
點兩下功能委派(管理下)
向下滾動到 IPv4 地址和域限制
- 將委派更改為讀/寫(在我的情況下,它是只讀的,這是問題所在)
希望這對其他人有幫助。
對於 Windows 10 和 Visual Studio 2015,請注意 ApplicationHost.config 文件已重新定位到項目文件夾層次結構中的 .vs\config 文件夾。您將需要編輯那裡找到的 ApplicationHost.config 文件的項目特定版本…
<section name="ipSecurity" overrideModeDefault="Allow" />如果您只編輯位於 Documents\IISExpress 文件夾中的 ApplicationHost.config,這不會影響您現有的應用程序(在我的例子中是 MVC5 應用程序)。