Website

New Project : Oil Price in Iceland

2 months ago I decided to act on an idea that had been floating around in my cranium for a long time.  It sounded simple enough,  gather all the data pertaining to the price of oil in Iceland in one location and present it on a simple front end.  However once I started working on it and the ball was rolling I learned it wasn't as simple as I thought it would be.  So during these past weeks I have learned a lo

Enumerate IIS Website Properties

  1. // ------------------------
  2. // This requires the following using statement
  3. using System.DirectoryServices;
  4. // ------------------------
  5.  
  6. // We connect to our desired web site
  7. DirectoryEntry de = new DirectoryEntry("IIS://localhost/w3svc/1234567890");
  8.  
  9. // Be advised that some property bindings (e.g. HttpRedirect) can only be set on a child object (e.g.

Enumerate IIS Websites

  1. // This code enumerates every Website on the local IIS server using C# and ADSI
  2.  
  3. // ------------------------
  4. // This requires the following using statement
  5. using System.DirectoryServices;
  6. // ------------------------
  7.  
  8. // Connect to the w3svc object
  9. DirectoryEntry w3svc = new DirectoryEntry("IIS://localhost/w3svc");
  10.  
  11. // Loop through all children
  12. foreach (DirectoryEntry child in w3svc.Children)
  13. {
  14.   // Grab the Website Object (IIsWebServer)
  15.   if (child .SchemaClassName == "IIsWebServer")
  16.   {
  17.     // Write out the name of the Website (ServerComment) and the Identifier (Name)
  18.     Con

Create IIS Website Programmatically

  1. // This code snippet shows how to programmatically create a new website in IIS via C# and ADSI
  2.  
  3. // ------------------------
  4. // This requires the following using statement
  5. using System.DirectoryServices;
  6. // ------------------------
  7.  
  8. // Connect to he ADSI Provider
  9. DirectoryEntry w3svc = new DirectoryEntry("IIS://localhost/w3svc");
  10.  
  11. // For a new website we need 3 things:
  12. // Server Comment - The name of the site as displayed by the IIS Manager
  13. // Server Bindings - The hostheader for the site in the form of IP:PORT:DOMAIN
  14. // Web root - Where the home directory for the new site resides
Syndicate content