I would like to build something in C# to edit the web.config of the web application.

I would like to enable the blob cache for the image renditions.

What is the best practice to edit the web.config Programmatically?

2 Answers 2


You can modify web.config settings is to use the SPWebConfigModification class of the Microsoft.SharePoint.Administration namespace, which allows you to dynamically register entities. These modifications are persisted in the configuration database where they function as a kind of virtual web.config that effectively serves as the final layer of the .config file stack for the SharePoint Foundation web application.

How to: Add and Remove Web.config Settings Programmatically

To enable Blob Cahce, please check this:

Enabling Blob Cache programmatically


You can read the following for general guidelines around Blob configuration for media in sharepoint

  1. Caching Best practices in SharePoint
  2. Blob configuration steps in SharePoint

This is pretty generic, but is a worthwhile read : Security Best Practices


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.