Author: Octavian Sfetcu

Creating new Web Application in code

A couple of days ago I wrote some code for creating a web application, configuring Claims Authentication and adding some alternate urls. I will share here the code with you: SPWebApplicationBuilder builder = new SPWebApplicationBuilder(SPFarm.Local); // This class is used for creating the web application. SPWebApplication webApp; builder.Port = 80; // Custom port number builder.AllowAnonymousAccess

Continue reading

Site Output Cache

Maybe one day in your SharePoint developer life you want to set the site Output Cache properties in your code. You can achieve that be using SiteCacheSettingsWriter class like in the following piece of code: SiteCacheSettingsWriter cacheSettingsWriter = new SiteCacheSettingsWriter(web.Site); cacheSettingsWriter.EnableCache = true; cacheSettingsWriter.SetAnonymousPageCacheProfileId(web.Site, 2); cacheSettingsWriter.SetAuthenticatedPageCacheProfileId(web.Site, 3); cacheSettingsWriter.SetFarmCacheFlushFlag(); cacheSettingsWriter.Update();