在简单的sharepoint项目中调用ashx处理程序时出错

时间:2013-09-02 04:10:55

标签: c# sharepoint ashx

当我浏览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。

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分: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