kevin
kevin

Reputation: 14095

error in calling ashx handler in simple sharepoint project

I got this error when I browsed web/_layouts/handler/ahandler.ashx

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

Here is my ashx page

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

Here is my 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
}

}

What could be the possible issue ? my .net framework is 3.5.

Upvotes: 1

Views: 2472

Answers (2)

Aurel76
Aurel76

Reputation: 36

ASHX files are not processed to replace the tokens by default, you can change this behaviour.

Steps to change this behaviour:

  1. Unload your Project, Edit the .csproj file and add the following text to a PropertyGroup, and reload your project

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

  1. More details can be found here: http://msdn.microsoft.com/en-us/library/ee231545.aspx

Source : 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

Upvotes: 0

Dennis G
Dennis G

Reputation: 21798

I'm pretty sure you will need to use the fully qualified name of the assembly instead of only using Class=BabyClubDemo.Layouts.Handler.AHandler.

A very similar response was posted on SharePoint Stackexchange: https://sharepoint.stackexchange.com/questions/19928/sharepoint-2010-and-ashx-handler

Upvotes: 1

Related Questions