2007-05-28

Launch ASP.NET Web Site Administration Tool without VS

This is copied from http://blogs.neudesic.com/blogs/phil_scott/archive/2006/07/04/187.aspx
Thank you Phil!


Create a batch file with:




@echo off

SET FrameWorkFolder=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

SET VFolder=Asp.NetWebAdminFiles

SET Port=8099

SET App=/Portal

SET AppPath=C:\Projects\SIS\Portal\

explorer "http://localhost:%Port%/%VFolder%/default.aspx?applicationPhysicalPath=%AppPath%&applicationUrl=%App%"

%FrameWorkFolder%\WebDev.WebServer.EXE /port:%Port% /path:%FrameWorkFolder%\%VFolder% /vpath:/%VFolder%

2007-05-14

Adding to web.config across farm with SPWebConfigModification

A web.config modification definition is expressed as a set of commands that, when processed by the web.config manipulator in Windows SharePoint Services, changes the state of web.config. You can string together a set of these commands to ensure that they apply the desired tags and attributes within web.config. Each modification is expressed as an object in the administrative object model.

Use the WebConfigModifications property of the SPWebApplication or SPWebService class to get the collection of web.config modifications either in the Web application or in all Web applications within the Web service.


Here's a console app as POC.

 


using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
class Program {
private const string ScriptResourceHandler = @"<add verb=""GET,HEAD"" path=""FOO.bar"" type=""System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions"" validate=""false""/>"
static void Main(string[] args)
{
SPSite siteCollection = new SPSite("http://localhost");
SPWebApplication webApp = siteCollection.WebApplication;
SPWebConfigModification modification = new SPWebConfigModification();
modification.Path = "configuration/system.web/httpHandlers"
modification.Name = "Example"
modification.Value = value;
modification.Owner = "ExampleOwner"
modification.Sequence = 0;
modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webApp.WebConfigModifications.Add(modification);
// .Remove doesn't remove it from the web.config, BTW... :(
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
}