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\" />"
};
webApplication.WebConfigModifications.Add(configModifications);
webApplication.Update();
webApplication.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
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?