LoggerHandler.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;

namespace SampleHttpModel.Handlers
{
    public sealed class LoggerHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            Debug.WriteLine(context.Request.RawUrl);
            
            context.Response.Write("sucess-HttpHandler");
            context.Response.End();
        }
    }
}

Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="Logger" path="*" verb="*" type="SampleHttpModel.Handlers.LoggerHandler" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
    <modules>
      <add name="LoggerModels" type="SampleHttpModel.HandlerModels.LoggerModels" preCondition="managedHandler" />
    </modules>
  </system.webServer>
</configuration>

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2021-06-22
  • 2021-09-17
  • 2021-07-15
猜你喜欢
  • 2022-12-23
  • 2021-07-28
  • 2022-02-06
  • 2022-12-23
  • 2021-10-13
  • 2021-10-08
  • 2021-09-13
相关资源
相似解决方案