在简单sharepoint项目中调用ashx处理程序时出错
本文关键字:处理 程序 出错 ashx 调用 简单 sharepoint 项目 | 更新日期: 2023-09-27 18:29:47
我在浏览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。
我确信您将需要使用程序集的完全限定名称,而不是仅使用Class=BabyClubDemo.Layouts.Handler.AHandler
。
SharePoint Stackexchange上也发布了类似的回复:https://sharepoint.stackexchange.com/questions/19928/sharepoint-2010-and-ashx-handler
默认情况下,ASHX文件不会被处理来替换令牌,您可以更改这种行为。
改变这种行为的步骤:
- 卸载您的项目,编辑.csproj文件并将以下文本添加到PropertyGroup,然后重新加载您的项目
2。<PropertyGroup>
<TokenReplacementFileExtensions>ashx</TokenReplacementFileExtensions>
</PropertyGroup>
- 更多详细信息,请点击此处: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