in

Agramont.net

VP of Mural Consulting...SaaS Strategy & Execution. Accelerated.

Provware

  • Provware Development Update

    It’s been a few weeks since I uploaded the first drop of Provware, so I thought I’d give everyone an update on what I’ve been working on. 

    New Features:

    • Commented all public methods
    • Documentation is now being built using Sandcastle!
    • Added to WebServer class: DeleteSite
    • Added to Site class: Start, Stop, DeleteVirtualDirectory
    • Increased performance of loading a “webServer” (when you have lots of sites) by only loading “partial” information.  This will still allow you to bind to a given site by name, but not have to wait a long time for the entire class structure to fully populate.
    • Tons of work in the Web Portal component.  I’m making it more of a web based control panel (not focused on a “hoster” CP, but more of a general Web UI for IIS Management…but more)

    I hope to have the next release out soon.  No dedicated date yet, but perhaps faster if I hear some demand.  (please….demand away!)

    Other features that “might” make the next build

    • Copy Site – Copy a site from one web server to another.  With an option to also move the content (not the permissions just yet)
    • Backup Web Server metabase - using built in IIS feature, but making the call easier to get to
    • Enable ASP.NET – This will allow you to enable,disable ASP.NET 1.1 or 2.0 via a single property change!!!

     

  • Provware: Getting Started (Build 001)

    What’s the Provware Framework?

    The Provware Framework is an API set built to make the interactions with IIS more intuitive and developer friendly.  For instance, the typical way that developers interact with IIS is via the DirectoryServices API of the .NET Framework.  This requires a fair amount of knowledge of how to program via ADSI and the IIS Metabase.  Since many people are just looking for a way to create sites, virtual directories, and application pools, this can be very difficult.  Thus the Provware Framework is born.  The Provware Framework provides a simple way to manage IIS components via .NET in a more “strongly typed” fashion.

    There are two core namespaces in the Provware Framework: Provware.Framework.IIS and Provware.Framework.Web.

    Provware.Framework.IIS
    This namespace provides the core abstraction of the DirectoryEntry object via the Provware Framework.  The main class in this namespace is the “IISManager” class.  The IISManager class is responsible for populating a given “IIS Class”.

    The following code example shows how to use the IISManager to populate an IIsWebServer class and then display all of the “Server Bindings” for the site in the console.

    IISManager iism = new IISManager();
    IIsWebServer myWeb = iism.GetIIsWebServer(“IIS://Localhost/w3svc/1”);
    foreach (string bind in myWeb.ServerBindings)
    {
     Console.WriteLine(bind);
    }

    As you can see, binding to the site is pretty much the same via the IISManager as it is with the DirectoryEntry class, but the call to the “ServerBindings” property is done via a property name of the class and not through a property bag (e.g. DirectoryEntryObject.Properties[“ServerBindings”]).  The advantage of doing it through a property is that you don’t have to guess what the write property name actually is or how it behaves (Boolean, Integer, String, or List).  The Provware Framework, and the Intellisense Support in Visual Studio, gives you the entire list during coding.

    Provware.Framework.Web
    This namespace goes much further in abstracting out the complexities of programming against IIS.  The overall goals of this namespace is to think more of IIS as a collection of sites and servers and interact with them as you would any other type of collection.

    The main entry point is the “WebManager” class.  It’s responsible for first “loading” the initial metabase objects (ApplicationPools and Sites) in the “WebServer” class of the framework.

    Here are some examples.

    Bind to a given Web Server

    WebManager wm = new WebManager();
    WebServer iisServer = wm.Connect(“Localhost”);

    Add new binding to the Default Site.  The Site Object is the core object, but all of the properties for this site are found by calling the IIsWebServer property.  This will return the IIsWebServer class which is based on the “Provware.Framework.IIS” namespace.

    Site defaultSite = iisServer.Sites[“Default Website”];
    defaultSite.IIsWebServer.ServerBindings.Add(“:8080:”);

    Create a new site – This call will take in the Site Name (aka ServerComment), initial Binding, content path, boolean if the content path should be created if it doesn’t exist.

    Site newSite = iisServer.CreateSite(“MySite”, “:80:www.mysite.com”,”C:\\Sites\\mySite\\Content\\Web”, true”);

    Get a DataTable of all the Sites for a given IIS Server – With the DataTable, it will make it much easier to display this information in a DataGrid or DataView in ASP.NET or a Windows Forms application.

    ArrayList returnList = new ArrayList();
    returnList.Add(“ServerComment”);
    returnList.Add(“ServerState”);
    returnList.Add(“ServerBindings”);
    DataTable props = iisServer.Sites.GetDataTableDetailed(returnList);

    Since this is the first build, all of the core features, error handling, or documentation are not anywhere complete.  I’m jazzed to at least have this first build and I’m very interested in getting a lot of feedback from my fellow .NET and IIS developer community friends so that I can improve on this class.  Performance of the class is a bit slow right now, but it will improve as the builds move forward.  I’m still bound to the performance issues involved in communicating with the IIS Metabase, but perhaps the benefits of the Provware Framework will make it worth the hit.

    I plan on making the source of this project available as well in the near future.

    There is a website/portal that comes with the Provware Framework download.  It’s not currently meant to be anything more than a sample of how to interact with the Framework, but I’m thinking of giving it more of a web based IIS Manager MMC/IIS Metabase Explorer type of life.  No plans are set in stone yet.

    Bonus Material: Provware IIS Class Builder

    In developing the Provware.Framework.IIS classes, I needed a way to build a C# class that had all of the same properties of a given IIS Metabase Class (e.g. IIsWebServer).  To do this, I wrote a program called the “Provware IIS Class Buider”.  It’s goal is to bind to an IIS site, get all of the properties available for a given IIS Metabase Class, and then dynamically build a C# class that contained a public property name (and correctly typed…string, boolean, Int32, and List) for each IIS Metabase property assigned to that IIS Metabase class type.  It was a lot of fun figuring this out.   Once I got the mechanics down, it worked for all IIS Metabase  classes.   Once you have all of the classes “built”, they are pretty much just empty shells.  If you have the desire to leverage this in your project, go for it.  These shell classes are a core part of the Provware.Framework.IIS namespace.
    The first version of this is available with the source in the below location.

     

  • How To: View Application Pool Identity for an IIS Website

    This example will show you how to create a new website using the Provware Framework (Build 001).

    1. Create a reference pointing to the Provware.Framework.dll assembly.
    2. Add a directive to use the "Provware.Framework.Web" namespace

      using Provware.Framework.Web;

    3. Add the following code to your C# application


                WebManager wm = new WebManager();
                // Connect to Server
                WebServer ws = wm.Connect("localhost");
               
                // Bind to site by SiteName (Provwware Terminology)/ServerComment
                Site defaultWeb = ws.Sites["Default Website"];

                // Get the Application Pool ID
                string defaultWebPool = defaultWeb.IIsWebServer.AppPoolId;

                // Bind to the Application Pool Object.
                ApplicationPool pool = ws.ApplicationPools[defaultWebPool];

                Console.WriteLine(pool.IIsApplicationPool.WAMUserName);

  • How To: Create a new Website

    This example will show you how to create a new website using the Provware Framework (Build 001).

    1. Create a reference pointing to the Provware.Framework.dll assembly.
    2. Add a directive to use the "Provware.Framework.Web" namespace

      using Provware.Framework.Web;

    3. Add the following code to your C# application

    WebManager wm = new WebManager();

    WebServer iisServer = wm.Connect("localhost");

    Site newSite = iisServer.CreateSite("My Site", ":80:www.mySite.com", "C:\\Sites\\mySite\\Content\\Web", true);

    At this point, the site is now created.  The "Site" object is part of the Provware Framework.  You can now use that object to interact with the site.

Copyright Agramont.net, 2006. all rights reserved