IIS 8.5,asp.net IHttpHandler 和 AppsendToLog

IIS 8.5 , asp.net IHttpHandler and AppsendToLog

我有一个处理程序,我尝试在其中写入接收到的数据 在 POST 中登录

context.Response.AppendToLog(result)

经过几次提示后,我在处理程序下添加了下一个设置:

<add name="test1" verb="*" path="*.ashx"  type="test1"/>

但这会导致下一个错误,我找不到解决方案:

Server Error in '/' Application.
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Could not load type 'test1'.
 Description: An unhandled exception occurred during the execution of the current web request. Please
        review the stack trace for more information about the error and where it originated in the code.
 Exception Details: System.Web.HttpException: Could not load type 'test1'.An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
HttpException (0x80004005): Could not load type &#39;test1&#39;.]
   System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +12495353
   System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +47
   System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +18
   System.Web.Configuration.HandlerFactoryCache..ctor(String type) +27
   System.Web.HttpApplication.GetFactory(String type) +94
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +375
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288
[HttpException]: Could not load type &#39;test1&#39;.
   at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
   at System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type)
   at System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type)
   at System.Web.Configuration.HandlerFactoryCache..ctor(String type)
   at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.GetFactory(String type)

哪个设置缺失或错误导致此错误?

我们通常在位于 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\

webconfig 文件中使用以下格式注册自定义 HTTP 处理程序 class
<system.web>
    <httpHandlers>
      <add path="*.jpg" verb="*" type="MyNameSpace.MyClass, MyDllName" />
    </httpHandlers>
 </system.web>

这种制作自定义处理程序的方法需要我们预编译 Customhanlder.cs 文件。

csc /t:library /r:System.Web.dll CustomHandler.cs

此外,ASHX 文件、通用处理程序是实现您的要求的常用方法。申请前无需注册

设置的正确位置:

<httpHandlers>
    <add name="test1" verb="*" path="*.ashx"  type="test1"/>
</httpHandlers>