The WebConfigFeatureReceiver is a feature receiver that reads XML files declared as "ElementFile" into the Feature.xml file. So the receiver must be set (attributes ReceiverAssembly and ReceiverClass) and XML files as to be in the feature folder hierarchy. The feature must be scoped to WebApplication, but it can be changed if you perform some modifications to the source code.

You can set the property UninstallInstallOnlyModifications to true in order to force removal of "install only" nodes.

Element filesare XML files that defines modifications to apply to targeted web application's Web.Config file. These files use most of the standard declaration for generic Web.config modifications when creating web applications (look at How To: Add Custom Configuration Settings to Extend a Web Application). You can add an extra attribute called installonly (set it to "true") on main nodes (add/update/remove) to don't uninstall them on feature deactivation. It can be useful for some important nodes that must not be removed even after feature deactivation.

Feature.xml Sample :

<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{5273CA58-BCBA-4b23-84AD-69918C8F8EB6}"
Title="$Resources:FeatureTitle;"
Description="$Resources:FeatureDescription;"
Scope="WebApplication"
ReceiverAssembly="SharePointOfView, Version=0.0.0.1, Culture=neutral, PublicKeyToken=85a56337686e234b"
ReceiverClass="SharePointOfView.EventReceivers.WebConfigFeatureReceiver"
DefaultResourceFile="_Res"
Hidden="FALSE"
ActivateOnDefault="FALSE"
Creator="SharePointOfView - www.codeplex.com/SharePointOfView"
>
<ElementManifests>
<ElementFile Location="ASPNetAJAXconfig.xml"/>
</ElementManifests>
<Properties>
<!-- Set to true if you want to uninstall even modifications that are marked as "installonly" -->
<Property Key="UninstallInstallOnlyModifications" Value="false"/>
</Properties>
</Feature>

Element File (XML) Sample
This file adds the AJAX ASP.Net support.

<?xml version="1.0" encoding="utf-8" ?>
<actions>
<add path="configuration/configSections">
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</add>
<add path="configuration/system.web/pages" installonly="true">
<controls />
</add>
<add path="configuration/system.web/pages/controls">
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</add>
<add path="configuration/system.web/compilation/assemblies">
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</add>
<add path="configuration/system.web/httpModules">
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</add>
<add path="configuration/system.web/httpHandlers">
<add verb="" path=".asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="" path="_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</add>
<add path="configuration/SharePoint/SafeControls">
<SafeControl Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />
</add>
<add path="configuration">
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
-->
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="ScriptHandlerFactory" verb="" path=".asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="" path="_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
</add>
</actions>

Last edited Jul 1, 2008 at 1:00 PM by GatWeb, version 1

Comments

No comments yet.