Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 18 | Comments: 81

filter by tags archive

I hate IIS today

time to read 1 min | 74 words

I am trying to execute the following piece of code:

Microsoft.Web.Administration.WebConfigurationManager.GetSection("system.webServer/httpHandlers");

Of course, this fails with a completely bizarre exception.

image

For some reason, I have the feeling it is not supposed to do that. Trying to explicitly pass the path where web.config lies also fails. When I finally made it use the correct path, it still gave the same error.

Urgh!


Comments

Joao Braganca

That should be system.webServer/handlers for IIS7 or system.web/httpHandlers for IIS6.

C-J Berg

So you are trying to read a non-standard section (or misspelled, but IIS cannot know that) that's not declared in configSections, and you then get upset because IIS tells you so, in plain english even? :-)

Try this:

WebConfigurationManager.GetSection("system.webServer/handlers");

Ricardo Stuven

For backward compatibility, you should change to "Classic" ASP.NET integration mode... or keep it "Integrated" and change the config file (system.web/httpHandlers -> system.webServer/handlers)

See http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/

Ayende Rahien

C-J Berg,

Um, no, it is a standard section, and notice what I am trying to do:

Microsoft.Web.Administration.WebConfigurationManager, this is using the IIS7 API, and I am trying to read the IIS 7 data.

Ayende Rahien

That is not what I want, I want to read the data from the IIS7 data, in integrated mode.

And I am using system.webServer/handlers, but that is not readable, unfortunately.

Ricardo Stuven

And I am using system.webServer/handlers

Your code and the error message say: "system.webServer/httpHandlers"

Ayende Rahien

Damn!

You are correct.

Thanks!

C-J Berg

What I meant was that it's not a standard section in IIS7; you used the standard name for IIS6 (hence the "misspelled").

Anyhow, if you want to manipulate the handlers section, Microsoft provides an assembly for that purpose: Microsoft.Web.Administration.dll (found in %SystemRoot%\System32\InetSrv). Its ServerManager lets you read the app's host config, and you can also update and save it. (It can also be used to control any other aspect of IIS7, so you no longer need to use WMI/ADSI to configure sites.)

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. The insidious cost of allocations - 18 hours from now
  2. Buffer allocation strategies: A possible solution - 4 days from now
  3. Buffer allocation strategies: Explaining the solution - 5 days from now
  4. Buffer allocation strategies: Bad usage patterns - 6 days from now
  5. The useless text book algorithms - 7 days from now

And 1 more posts are pending...

There are posts all the way to Sep 11, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    03 Sep 2015 - The industry at large
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats