get the handler mappings from iis7 using

Posted on 2014-08-14
Last Modified: 2014-08-28
Ok, here is the question. Can I get the handler mappings from the iis7 that is config for my website hosted on iis using coding. Lets say I want to get all the handler mappings, then I want to add them to my web.config later to move to another hosting server and migrate the config from the iis7, so I don´t get errors about handler mappings.
Question by:rafaelrgl
    LVL 96

    Expert Comment

    by:Bob Learned
    I believe that you can use the Microsoft.Web.Administration.ServerManager to get that information:

    using (ServerManager serverManager = new ServerManager())
                SiteCollection sitecollection = serverManager.Sites;
                Configuration webConfig = serverManager.GetWebConfiguration("Default Web Site");
                ConfigurationSection handlersSection = webConfig.GetSection("system.webServer/handlers");
                ConfigurationElementCollection handlersCollection = handlersSection.GetCollection();
                foreach (var handler in handlersCollection)

    Open in new window

    LVL 96

    Accepted Solution


    Using serverManager As New ServerManager()
    	Dim sitecollection As SiteCollection = serverManager.Sites
    	Dim webConfig As Configuration = serverManager.GetWebConfiguration("Default Web Site")
    	Dim handlersSection As ConfigurationSection = webConfig.GetSection("system.webServer/handlers")
    	Dim handlersCollection As ConfigurationElementCollection = handlersSection.GetCollection()
    	For Each handler As var In handlersCollection
    End Using

    Open in new window


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now