簡體   English   中英

除非存在會話,否則不調用ASP.NET HttpHandler

[英]ASP.NET HttpHandler not called unless there is a Session

我創建了一個非常簡單的ASP.NET HttpHandler,由於某種原因,除非用戶登錄,否則不會調用它。 我已將其分配為處理PNG圖像。 對於首次訪問該網站的訪問者,不會調用該處理程序。 他們登錄后,便會被調用。 我在經典模式下的Windows 7上使用.NET 4,IIS7。 所請求的PNG圖像在文件目錄中不存在。

namespace MyNS
{
   public class MyHttpHandler : IHttpHandler 
   {
       public bool IsReusable { get { return true; } }
       public void ProcessRequest( HttpContext context ) 
       { }
   }
}

在我的web.config中,我有...

<system.webServer>
    <handlers>
   <add name="MyPNG" path="*.png" verb="*" type="MyNS.MyHttpHandler" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,bitness64" />
    </handlers>
</system.webServer>

首先,如果您在經典模式下使用IIS7,則必須在兩個位置設置config: link

另外,您還需要從身份驗證中排除處理程序:

<location path="myhandler URL">
            <system.web>
                    <authorization>
                            <allow users="*"/>
                    </authorization>
            </system.web>
</location>

更新

好,這是我的意思:

<location path="*.png">
            <system.web>
                    <authorization>
                            <allow users="*"/>
                    </authorization>
            </system.web>
</location>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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