使用httpHandler时出错.无法加载文件或程序集或其依赖项之一

本文关键字:程序集 依赖 文件 httpHandler 出错 加载 使用 | 更新日期: 2023-09-27 18:12:25

我试图在asp.net中使用HttpHandler。我在Web中做了以下更改。配置文件。

<httpHandlers>
    <add verb="*"path="Crm"validate="false"type="PracticeWeb.ApplicationController,PracticeWeb"/>
</httpHandlers>

也在ApplicationController.cs文件

public class ApplicationController : System.Web.UI.Page, System.Web.IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
    public ApplicationController()
    {
        //
        // TODO: Add constructor logic here
        //..
    }
    public  void ProcessRequest(HttpContext context)
    {
        HttpRequest Request = context.Request;
        HttpResponse Response = context.Response;
        // This handler is called whenever a file ending 
        // in .sample is requested. A file with that extension
        // does not need to exist.
        Response.Write("<html>");
        Response.Write("<body>");
        Response.Write("<h1>Hello from a synchronous custom HTTP handler.</h1>");
        Response.Write("</body>");
        Response.Write("</html>");
    }
    public bool IsReusable
    {
        // To enable pooling, return true here.
        // This keeps the handler in memory.
        get { return false; }
    }
}

我得到以下错误。在Web的下面一行。配置

<add verb="*" path="Crm" validate="false" type="PracticeWeb.ApplicationController,PracticeWeb"/>

配置错误描述:在处理处理此请求所需的配置文件期间发生错误。请查看下面的具体错误细节,并适当修改您的配置文件。

解析器错误消息:无法加载文件或程序集'PracticeWeb'或其依赖项之一。系统找不到指定的文件

访问应用程序的Url。http://localhost: 1300/WebSitesPrac/Crm

使用httpHandler时出错.无法加载文件或程序集或其依赖项之一

ApplicationController继承自System.Web.Page。尝试将其从类定义中删除,只实现IHttpHandler和IRequiresSessionState。

通过从WebForms的基本类型派生,你的处理程序将在运行时加载许多其他类型。我不确定这是否是问题的根本原因,但这是一个很好的开始。