[英]IIS 8.5 , asp.net IHttpHandler and AppsendToLog
i have an handler, in which i try to write the data received in POST to log我有一个处理程序,我尝试将在 POST 中收到的数据写入日志
context.Response.AppendToLog(result)
after few hints i got i added the next settings under handlers:在得到一些提示后,我在处理程序下添加了下一个设置:
<add name="test1" verb="*" path="*.ashx" type="test1"/>
but this causing the next error which i can't find a solution for:但这会导致下一个错误,我找不到解决方案:
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 'test1'.] 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& completedSynchronously) +288 [HttpException]: Could not load type 'test1'. 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)
which setting is missing or is wrong that causing this error?哪个设置丢失或错误导致此错误?
We usually register the Custom HTTP handler class with the below format in the webconfig
file located C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\
我们通常在位于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>
This way of making the custom handler requires us to precompile the Customhanlder.cs
file.这种制作自定义处理程序的方式需要我们预编译Customhanlder.cs
文件。
csc /t:library /r:System.Web.dll CustomHandler.cs
Besides, the ASHX file, Generic handler is a common way to achieve your requirement.此外,ASHX 文件,通用处理程序是实现您的要求的常用方法。 There is no need to register it before applying it.申请前无需注册。
the correct place to locate the settings:找到设置的正确位置:
<httpHandlers>
<add name="test1" verb="*" path="*.ashx" type="test1"/>
</httpHandlers>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.