I am trying to create a Custom Server Control in C# using VS2008. I am using this custom control that actually requires me to modify the web.config file in order to add an HttpHandler when this control is added to the page of client.
My question is fairly simple:
What needs to be added to my custom control code so it registers the required HttpHandler information in the web.config? Some native controls already do this. For example, the AJAX Toolkit will modify the web.config. How can I do something similar with my control?
If you have an item in the toolbox of Visual Studio you can perform such an action when the developer drags and drops the control onto the web page. You need to decorate your control with
System.ComponentModel.DesignerAttributeto refer it to a subclass (which you create) ofSystem.Web.UI.Design.ControlDesigner. In this class you can overrideInitializeand in there you can get hold of the config viaSystem.Web.UI.Design.IWebApplicationsomething like this: