1

浏览 web/_layouts/handler/ahandler.ashx 时出现此错误

 An error occurred during the processing of /_layouts/handler/ahandler.ashx. Could not create type 'BabyClubDemo.Layouts.Handler.AHandler'.

这是我的 ashx 页面

<%@ WebHandler Language="C#" CodeBehind="AHandler.ashx.cs" Class="BabyClubDemo.Layouts.Handler.AHandler" %>

这是我的 ashx.cs

using System;
using System.Web;

namespace BabyClubDemo.Layouts.Handler
{
public class AHandler : 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)
    {
        context.Response.Clear();
        context.Response.ContentType = "application/json; charset=utf-8";
        context.Response.Write(CallServerFunction(context));
    }

    private string CallServerFunction(HttpContext context)
    {

        return "testing the applicaiton";
    }

    #endregion
}

}

可能是什么问题?我的 .net 框架是 3.5。

4

2 回答 2

1

我很确定您将需要使用程序集的完全限定名称,而不是仅使用Class=BabyClubDemo.Layouts.Handler.AHandler.

在 SharePoint Stackexchange 上发布了一个非常相似的回复:https ://sharepoint.stackexchange.com/questions/19928/sharepoint-2010-and-ashx-handler

于 2013-09-02T06:57:07.067 回答
0

默认情况下,不会处理 ASHX 文件来替换令牌,您可以更改此行为。

改变这种行为的步骤:

  1. 卸载您的项目,编辑 .csproj 文件并将以下文本添加到 PropertyGroup,然后重新加载您的项目

2. <PropertyGroup> <TokenReplacementFileExtensions>ashx</TokenReplacementFileExtensions> </PropertyGroup>

  1. 更多细节可以在这里找到:http: //msdn.microsoft.com/en-us/library/ee231545.aspx

来源:https ://social.msdn.microsoft.com/Forums/en-US/a69a09de-c928-4570-bef3-ae446cb6eac6/why-do-i-get-quotcould-not-load-the-assembly-sharepointprojectassemblyfullname- make-sure?forum=sharepointdevelopmentprevious

于 2019-08-08T13:25:05.057 回答