locked
HTTPHandler not working in Sharepoint 2010 SiteDefinition Project RRS feed

  • Question

  • User127115863 posted

    I'm currently working on a SharePoint SiteDefinition(Re-Branding) and have written a couple of HttpHandlers to respond to incoming requests but they just don't want to work.  I have been searching for a solution for to long; about the project:

    • HttpHandlers reside in the _layouts/project/*.ashx folder for the project
    • I have tried the following:
      • Single page (no code behind)
        • But this gives me an issue with the using directive for System.Data.Linq . Linq will not load properly, System and System.Data are both fine!
      • With code behind - with and without the project namespace
      • With and Without standard SharePoint Assembly references

    The general error I receive is:

    System.Web.HttpParseException: Could not create type 'BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition.sqlRequestHandler'.  
     at System.Web.UI.SimpleWebHandlerParser.GetType(String typeName)   
     at System.Web.UI.SimpleWebHandlerParser.GetTypeToCache(Assembly builtAssembly)   
     at System.Web.Compilation.SimpleHandlerBuildProvider.GetGeneratedType(CompilerResults results)   
     at System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results)   
     at System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results)   
     at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)   
     at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)   
     at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)   
     at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)   
     at System.Web.UI.SimpleHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)   
     at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    The Handler:

    <%@ WebHandler Language="C#" Debug="true" Class="BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition.sqlRequestHandler" CodeBehind="sqlRequestHandler.ashx.cs" %>

    CodeSide:

    using System;
    using System.Web;
    using System.Data;
    using System.Data.Linq;

    using BG.HandbooksForBGWEB;

    namespace BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition
    {
        public partial class sqlRequestHandler : IHttpHandler
        {

            public void ProcessRequest(HttpContext context)
            {

                switch (context.Request.Form["func"])
                {
                    case "subjects":
                        GetSubjectsByYearLevel(Convert.ToInt16(context.Request.Form["yearlevel"]));
                        break;
                    default:
                        break;
                }

            }

            private string GetSubjectsByYearLevel(int yearLevel)
            {
                string output = null;

                clsHandbooks chb = new clsHandbooks();

                output = chb.ReturnCoreSubjectsByYearLevel(yearLevel);
                output += chb.ReturnElectiveSubjectsByYearLevel(yearLevel);

                return output;
            }

            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }

        }
    }

    Has anyone had similar problems as I can't find many posts about this happening, thanks JJ

    :BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition
    Thursday, October 6, 2011 3:59 AM

Answers

  • User423092291 posted

    Hello!

    Is the dll containing BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition.sqlRequestHandler in GAC?

    And why is namespace BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition is so strange? For the sake of experiment try simplier name space without repeating substrings. For example, only BG.WEB.SiteDefinition.Layouts

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 8, 2011 1:07 AM

All replies

  • User423092291 posted

    Hello!

    Is the dll containing BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition.sqlRequestHandler in GAC?

    And why is namespace BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition is so strange? For the sake of experiment try simplier name space without repeating substrings. For example, only BG.WEB.SiteDefinition.Layouts

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 8, 2011 1:07 AM
  • User127115863 posted

    Hi,

    The code for BG.WEB.SiteDefinition.Layouts.BG.WEB.SiteDefinition.sqlRequestHandler is compiled with the SiteDefinition and is in the GAC.

    The reason for the long namespace is that

    • BG.WEB.SiteDefinition is the project
    • Layouts.BG.WEB.SiteDefinition is the location of the file
    • sqlRequestHandler is the file

    I have tried useing just the location, so : Layouts.BG.WEB.SiteDefinition.sqlRequestHandler but still no luck

    I have now gnoe back to using a single page Handler with the code on the same page and have maanaged to get it working, however I'm facing the same problem with another handler.  I will try your suggestions and let you know.

    Thanks

    Monday, October 10, 2011 1:58 AM