I have an MVC web app(.net framework 4.8) and I want to update the sessionState element(child element of system.web) dynamically in Web.config . I am using an external config file for the sessionState element and updating this file dynamically. eg:
<sessionState configSource="Configs\SessionState.config" />
The config file is getting updated as expected but the app is getting restarted due to this. I am trying to avoid the app restart here. I am trying to achieve that using restartOnExternalChanges property of sessionState section. Is there any way to override the machine.config's sessionState section in the web app's web.config something like(this will throw an error "There is a duplicate 'system.web/sessionState' section defined"),
<sectionGroup name="system.web" type="System.Web.Configuration.SystemWebSectionGroup, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<section name="sessionState" restartOnExternalChanges="false" type="System.Web.Configuration.SessionStateSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</sectionGroup>
The machine.config's sessionState config section looks like
<sectionGroup name="system.web" type="System.Web.Configuration.SystemWebSectionGroup, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<section name="sessionState" type="System.Web.Configuration.SessionStateSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineToApplication"/>
</sectionGroup>