Posts

Showing posts with the label SharePoint Server

Activate SharePoint Server Publishing Infrastructure Programmatically (SharePoint 2010)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using Microsoft.Office.Server; using Microsoft.Office.Server.Audience; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint.Navigation; namespace ConsoleOperations {     class ActivatePublishingFeature     {         static void Main(string[] args)         {             try             {                 using (SPSite site = new SPSite("http://localhost:5012/"))                 {                     using (SPWeb web = site.RootWeb)                     {                         Guid sitePub...

Modifying web.config programatically (SharePoint2010)

Here i'm going to add 2 web.config entries through code first i'm taking the backup copy of the original web.config and i'm adding the new entries. Code shown below... using System ; using System.Collections.Generic ; using System.IO ; using System.Linq ; using System.Text ; using Microsoft.SharePoint ; using Microsoft.SharePoint.Administration ; using System.Web.Administration ; using System.Configuration ; using System.Web ; using System.Web.Configuration ; using System.Reflection ; using System.Xml ; using System.Xml.Xsl ; using System.Xml.Serialization ; using System.Xml.XPath ; namespace ConsoleApplicationWebConfigBackUp { class Program { static void Main ( string [] args) { ApplyWebConfigModifications( "http://localhost:5050" ); //Taking the backup of the web.config file string physicalPath = oSite.WebApplication.IisSettings[SPUrlZone.Default].Path.ToString(); File.Copy(physical...