SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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