2011-09-01 23 views
2

我有一個使用基本身份驗證的IIS 7上的網站。有些頁面必須公開。我在web.config配置要素添加了此異常,它看起來像這樣:IIS 7基本身份驗證位置問題

<location path="Errors"> 
    <system.webServer> 
     <security> 
     <authorization> 
      <remove users="*" roles="" verbs="" /> 
      <add accessType="Allow" users="*" /> 
     </authorization> 
     </security> 
    </system.webServer> 
    </location> 

但是,如果我嘗試從該文件夾訪問某些文件,我得到這個錯誤:

HTTP Error 401.2 - Unauthorized You are not authorized to view this page due to invalid authentication headers. Detailed Error Information Module IIS Web Core Notification AuthenticateRequest Handler StaticFile Error Code 0x80070005 Requested URL http://srv/Errors/error401.htm Physical Path D:\www\MyApp\Errors\error401.htm Logon Method Not yet determined Logon User Not yet determined

如何在我的網站上進行基本身份驗證,但是允許所有人訪問錯誤目錄?

回答

0

IIRC,「?」對匿名用戶...所以啓用匿名身份驗證藏漢並把這個在你的web.config ...希望你的作品...

IIS7

<location path="Errors"> 
    <system.webServer> 
    <security> 
     <authorization> 
     <remove users="*" roles="" verbs="" /> 
     <add accessType="Allow" users="*" /> 
     </authorization> 
    </security> 
    </system.webServer> 
</location> 

IIS6(或IIS7經典模式)

<location path="Errors"> 
    <system.web> 
    <authorization> 
     <allow users="?" /> 
    </authorization> 
    </system.web> 
</location> 

編輯

我不確定刪除已認證的用戶(*)是否是一個好主意,儘管...認證的用戶也可以獲得錯誤...向他們展示一些愛...;)

編輯2(IIS7中改變了傳統模式)

+0

不幸的是,不能正常工作。我已經嘗試過*和?的每個組合。但沒有... – user328087

+0

您的應用程序池是否設置爲集成模式? – gislikonrad

+0

不,我使用經典模式。 – user328087