Last post Sep 04, 2015 03:31 PM by rstrahl
Aug 20, 2015 01:01 AM|luckyforu2006|LINK
Is there a way to remove following setting of web.config file at runtime.
<validation validateIntegratedModeConfiguration="false" />
<remove name="ClaimsPrincipalHttpModule" />
<remove name="SitefinityClaimsAuthenticationModule" />
<remove name="Sitefinity" />
<remove name="SessionAuthenticationModule" />
<remove name="ScriptModule" />
<remove name="RadUploadModule" />
<remove name="SitefinityAnalyticsModule" />
I tried writing below code for the same.
public class Global : System.Web.HttpApplication
// some modules use explicit interface implementation
// by declaring this static member as the IHttpModule interface
// we work around that
public static IHttpModule Module = new xrnsToashxMappingModule();
public override void Init()
Any help will be highly appreciated.
Sep 04, 2015 03:31 PM|rstrahl|LINK
The code you referenced is from my blog a long time ago and that works only to *add* a module dynaimcally at runtime. You can't use it to remove modules or other content from Web.config. What you are trying to do is essentially override a setting.
The easiest and most consistent (but hacky) way to do this is to just an XML parser to load the web.config as an XML document, update it and write back out. There are APIs that allow writing settings but they require special components that may not be present
and full admin rights so in many cases it's just easier to load the document up and modify it directly.
You can use Linq to XML to make this pretty painless or XmlDocument if you want a more traditional approach.
Note that you will need to make sure that your application pool has WRITE access to the web.config file in order for this to work.
+++ Rick ---