SaaS CMS has officially launched! Learn more now.

How to patch new properties in web.config


Hi Guys,

I have a requirement of patching some properties to the existing web.config. I am trying to do it via Add-on so i dont have access to web.config but i want to make my property added to the web.config of the user who uses my Add-on.

Example : 

For the below section in the web.config i want to add the language1 from a external config file which comes as part of add-on.

<profile defaultProvider="DefaultProfileProvider">
<add name="Address" type="System.String" />
<add name="ZipCode" type="System.String" />
<add name="Locality" type="System.String" />
<add name="Email" type="System.String" />
<add name="FirstName" type="System.String" />
<add name="LastName" type="System.String" />
<add name="Language" type="System.String" />
<add name="Country" type="System.String" />
<add name="Company" type="System.String" />
<add name="Title" type="System.String" />
<add name="CustomExplorerTreePanel" type="System.String" />
<add name="FileManagerFavourites" type="System.Collections.Generic.List`1[System.String]" />
<add name="EditTreeSettings" type="EPiServer.Personalization.GuiSettings, EPiServer.Cms.AspNet" />
<add name="ClientToolsActivationKey" type="System.String" />
<add name="FrameworkName" type="System.String" />
<add name="Language1" type="System.String"/>

Do we have any thing similar like patching we can do for the same? Any specific process like transformation for environments in DXC.



Oct 25, 2019 16:13
Oct 26, 2019 6:12

Hi Ravindra,

Thanks for your response.

Is there any other way by using only configs like any transform files or any specific that episerver will pick the config from another config file.

Because the change which I wanted to make should exist all the time and it is part of add-on, so I may not have the initial call with me.



Oct 26, 2019 6:31

Then you can apply it using the tranform file using the visual studio slow cheetah extension.

Oct 26, 2019 6:51

As I am using it from add-on , I don't have that feasibility of updating using transforms. Because add-on once installed it will copy my dlls and config. So I won't have the access to the code base. What I am developing is a add-on and in that add-on I require changes in web.config.



Oct 26, 2019 7:19

I think you can use Episerver initialization module in your add on and then write the logic in initialization module to update the values in web.config. I haven't tried this but I think it should work.

Refer my above blog post to update the property in web.config

Edited, Oct 26, 2019 11:47

Writing in web.config on runtime is simply and strongly not recommended, the reason is obvious that there will be an application to recycle all the time, think can go more complex if the site is in the cloud. Site visitors will face downtime. and will not be able to do any further action on AddOn also.

There are many ways to manage this depending on requirements, hope you would have already visitied


Oct 26, 2019 13:40

if add-on is not deterministic - you might get into infite restart loop (app starts -> addon writes to web.config -> app restarts -> addon writes to web.config -> repeat..)

please don't touch web.config -> it's not recommneded. 

if you need modify profile for example -> I would recommend to create web.config transform file (web.config.transform) where you can add your required changes. these changes will be applied during nuget package installation. more info -

Oct 26, 2019 14:15
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.