[英]Allow anonymous access to a directory in a IIS site that uses Windows Authentication
我有一個使用Windows身份驗證運行ASP.NET 4.0的IIS8站點。
在我的IIS身份驗證設置中,除Windows身份驗證外,所有都被禁用 用戶可以正確進行身份驗證並按預期使用該站點。
但是,我現在有一個Uploads文件夾,其中包含我想要從其他應用程序向未經過身份驗證的用戶公開的圖像。
在我的web.config文件中,我有以下與認證/授權相關的行:
<system.web>
<authentication mode="Windows"/>
</system.web>
<location path="Uploads">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
如何允許匿名訪問uploads文件夾,同時保留其他所有內容的Windows身份驗證? 目前,他們必須登錄到其他應用程序,然后在從相關站點訪問圖像時,他們必須進行身份驗證才能訪問它們。
另外,位置路徑是相對於web.config文件正確的嗎?
編輯:不確定這是否重要,但我們的網站內部和外部都可用。 如果從我們域上的計算機訪問,它會自動登錄,如果它是不在域中的計算機,則會將它們重定向到登錄頁面。
我在另一個問題上找到了答案: 允許對web.config中的單個文件夾進行匿名身份驗證?
碼:
<location path="Path/To/Public/Folder">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
您需要做的是刪除匿名的“拒絕”規則,因為它繼承了它仍然會阻止用戶,例如:
<system.webServer>
<security>
<authorization>
<remove users="?" roles="" verbs="" />
<allow users="*" />
</authorization>
</security>
</system.webServer>
實際上,位置路徑是相對於web.config所在的文件夾。
我還注意到你使用的是system.web而不是system.webServer,這是你應該使用的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.