Get IIS bindings at runtime without being an Administrator

Today there was a question in StackOverflow asking whether it was possible to read the IIS binding information such as Port and Protocols from the ASP.NET application itself to try to handle redirects from HTTP to HTTPS in a way that was reliable without worrying about using different ports than 80/443. Turns out this is…


IIS 7.0 Site ID Computation

In my previous post I mentioned that IIS Manager (more specifically Microsoft.Web.Administration) has two algorithms for assigning a Site ID when no ID is specified. The two algorithms are: Incremental Site ID. When this algorithm is configured we will assign the first consecutive number available, for example, if you have Site ID’s 1,2,3,5,6,8 the next…


Faster IIS Web Sites Provisioning using Microsoft Web Administration

Yesterday I got an email about some performance numbers that one of our customers were running into when creating remotely Web Sites, Applications, Application Pools and other tasks in IIS using Microsoft.Web.Administration. In case you don’t know Microsoft.Web.Administration is a .NET library that exposes the IIS Configuration System. The code was using Microsoft.Web.Administration from PowerShell…


How to register a new Section Definition using Microsoft.Web.Administration

Today I was asked how can someone would be able to add a new section definition using Microsoft.Web.Administration, so I thought I would post something quickly here just to show how this could be achieved. using System; using Microsoft.Web.Administration; class Program {     static void Main(string[] args) {         using (ServerManager m = new ServerManager()) {             Configuration config = m.GetApplicationHostConfiguration();             SectionDefinition definition =                 RegisterSectionDefinition(config, “system.webServer/mySubgroup/mySection”);             definition.OverrideModeDefault = “Allow”;             m.CommitChanges();        …


Search your configuration sections in web.config files using IIS 7.0 API’s

Background In IIS 7.0 we have the great functionality to allow you to configure the Web Server settings in a distributed way, including the IIS configuration along with the ASP.NET configuration in the web.config files by using Configuration Sections. For example, the following shows a web.config adding a default document (home.aspx) to a Web Application…


Using Microsoft.Web.Administration in Windows PowerShell

A couple of months ago I wrote about using LINQ with Microsoft.Web.Administration to manage and query IIS 7.0 configuration. Somebody came back to me and said that LINQ was very cool but that it was very much Developer oriented and that in a production server without VS or .NET 3.5 it wouldn’t be an option….


Using LINQ with Microsoft.Web.Administration

With the upcoming release of .NET 3.5 and LINQ I thought it would be interesting to show some of the cool things you can do with IIS 7 and LINQ. Everything that I will do can be done with C# 2.0 code but it would take me several lines of code to write them but…


Using the IIS 7.0 Managed Configuration API

More than a year ago I wrote about Microsoft.Web.Administration.dll and how it was a new API we were creating for managed code developers to be able to easily set any configuration settings of IIS, however I purposely ignored the configuration part of the API. Later I talked about the way configuration was organized in IIS…


Microsoft.Web.Administration in IIS 7

While creating the new administration stack in IIS 7, we were looking into the different ways users could manipulate the server configuration as well as the new runtime information available in IIS 7 (Internally we call this RSCA-Runtime State and Control API) from managed code, and we realized we needed to provide a simpler and…