[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

get the handler mappings from iis7 using asp.net

Ok, here is the question. Can I get the handler mappings from the iis7 that is config for my website hosted on iis using asp.net 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.
  • 2
1 Solution
Bob LearnedCommented:
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

Bob LearnedCommented:

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now