簡體   English   中英

允許匿名訪問使用Windows身份驗證的IIS站點中的目錄

[英]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中的單個文件夾進行匿名身份驗證?

  1. 首先,我必須進入C:\\ Windows \\ System32 \\ inetsrv \\ config \\ applicationHost.config
  2. 搜索此行,並更改為“允許”而不是“拒絕”
  3. 然后將下面的代碼放入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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM