I'm trying to update web.config in SharePoint when the feature is activated to register an HttpHandler. The code inside receiver is

var configModifications = new SPWebConfigModification
    Owner = "Request Handler",
    Path = "configuration/system.webServer/handlers",
    Name = "add[@name='RequestHandler']",
    Sequence = 0,
    Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
    Value = "<add name=\"RequestHandler\" verb=\"*\" path=\"*.html\" type=\"DivisionRequestHandler.RequestHandler\" resourceType=\"File\" preCondition=\"integratedMode\" />"


When I'm deploying feature I have received the following error: "Expression must evaluate to a node-set." Handler assembly is deployed to application bin folder via SharePoint solution without any issues. Also, I tried to add handler via IIS Handler Mapping. This working successfully without any issues. But I'm in a need to add to web.config programmatically via SharePoint feature.

Has any of you experienced the same thing? Any suggestion?

1 Answer 1


The easiest way to create a HttpHandler is to create a .ashx file. After you create an .ashx file that defines an HttpHandler component, you must deploy it within the \LAYOUTS directory as you would deploy a custom application page. See this post for more datails.

In this case you should not modify web.cfg. In my practice it is the best way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.