簡體   English   中英

httphandler攔截在IIS 7.0中不起作用

[英]httphandler intercept not working in IIS 7.0

我在.netframework 2.0中完成了一個應用程序,並嘗試在以3.5框架編寫的安全項目中使用身份驗證處理程序。 我也在使用IIS 7

應用程序的Web.config具有以下條目

<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <handlers  accessPolicy="Read, Write, Script, Execute">

      <add name="Pdfhandler" verb="*" path="/calderdale/*.pdf" type="NES.HiLo.Security.CalderDaleAuthenticationHandler, NES.HiLo.Security" preCondition="integratedMode" />
  </handlers>

 </system.webServer>

CalderDaleAuthenticationHandler的代碼是

using System;
using System.Web;

namespace NES.HiLo.Security
{
    public class CalderDaleAuthenticationHandler : IHttpHandler
    {
        /// <summary>
        /// You will need to configure this handler in the web.config file of your 
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        #region IHttpHandler Members
    public bool IsReusable
    {
        // Return false in case your Managed Handler cannot be reused for another request.
        // Usually this would be false in case you have some state information preserved per request.
        get { return false; }
    }

    public void ProcessRequest(HttpContext context)
    {
        //var application = (HttpApplication)sender;
        //var context = application.Context;

        HttpRequest request = context.Request;
        HttpResponse response = context.Response;


      // Check if the user is authenticated

    }

    #endregion
}

}

在我的應用程序中,我有一個名為calderdale的文件夾,並且有一些pdf文件。 當我鍵入如下內容以訪問pdf文件時。 我期望控件進入設置斷點的處理程序。 控件永遠不會傳遞給處理程序。 感謝您的幫助。

http://local.knowledge.scot.nsh.uk/calderdale/abc.pdf

我使用httphandlers攔截請求。 然后在web.config中添加這樣的處理程序

<httpHandlers>
  <add verb="GET" path="calderdale/*.pdf"
   type="NES.HiLo.Security.CalderDaleAuthenticationHandler, NES.HiLo.Security" />
</httpHandlers>

在IIS 7.0上執行上述操作之后,我從IIS處理程序部分添加了以下處理程序

<system.webServer>  
  <handlers>
    <add name="Calderdale Handler" path="calderdale/*.pdf"
     verb="GET" modules="IsapiModule"
     scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
     resourceType="Unspecified" requireAccess="Script"
     preCondition="classicMode,runtimeVersionv2.0,bitness32" />
  </handlers>
</system.webServer>

暫無
暫無

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

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