How to access system.webserver web.config node in .NET 2

Posted by JK on Stack Overflow See other posts from Stack Overflow or by JK
Published on 2010-03-24T09:01:12Z Indexed on 2010/03/24 9:03 UTC
Read the original article Hit count: 292

Filed under:
|

Are there any .NET APis that can read/update the system.webServer node in web.config? I know I can do it via reading/parsing the web.config file as xml but that's awkward.

To read/update the system.web node in .NET 2 I can use:

HttpModulesSection httpModulesSection = (HttpModulesSection)configuration.GetSection("system.web/httpModules");

But is there any API based way of accessing system.web/modules using .NET 2?

I have to reference the .NET 2 version of system.web.configuration because I don't know in advance if my web app will be run on a server with .NET 2 or 3.5. So it is limited to .NET 2 API calls only.

Thanks

© Stack Overflow or respective owner

Related posts about c#2.0

Related posts about web.config